Fixed api issues, missing deps and got first endpoint to work

This commit is contained in:
Vasilije 2023-11-17 21:13:42 +01:00
parent ef7d1b3bc7
commit b2e6302ae2
2 changed files with 19 additions and 3 deletions

View file

@ -10,7 +10,7 @@ class MemoryModel(Base):
id = Column(String, primary_key=True)
user_id = Column(String, ForeignKey('users.id'), index=True)
operation_id = Column(String, nullable=True)
operation_id = Column(String, ForeignKey('operations.id'), index=True)
memory_name = Column(String, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow)
updated_at = Column(DateTime, onupdate=datetime.utcnow)

View file

@ -24,6 +24,7 @@ from cognitive_architecture.database.postgres.models.metadatas import MetaDatas
from cognitive_architecture.database.postgres.models.docs import DocsModel
from cognitive_architecture.database.postgres.models.memory import MemoryModel
from level_4.cognitive_architecture.database.postgres.models.user import User
# Adds response_model to ChatCompletion
# Allows the return of Pydantic model rather than raw JSON
@ -150,11 +151,16 @@ async def get_vectordb_data(session: AsyncSession, user_id: str):
async def load_documents_to_vectorstore(session: AsyncSession, user_id: str, job_id:str=None, loader_settings:dict=None):
namespace_id = str(generate_letter_uuid()) + "_" + "SEMANTICMEMORY"
namespace_class = namespace_id + "_class"
try:
new_user = User(id=user_id)
await add_entity(session, new_user)
except:
pass
if job_id is None:
job_id = str(uuid.uuid4())
memory = await Memory.create_memory(user_id, session, namespace=namespace_id, job_id=job_id, memory_label=namespace_id)
await add_entity(
session,
Operation(
@ -165,6 +171,10 @@ async def load_documents_to_vectorstore(session: AsyncSession, user_id: str, job
),
)
memory = await Memory.create_memory(user_id, session, namespace=namespace_id, job_id=job_id, memory_label=namespace_id)
document_names = get_document_names(loader_settings.get("path", "None"))
for doc in document_names:
@ -217,6 +227,12 @@ async def load_documents_to_vectorstore(session: AsyncSession, user_id: str, job
async def user_query_to_graph_db(session: AsyncSession, user_id: str, query_input: str):
try:
new_user = User(id=user_id)
await add_entity(session, new_user)
except:
pass
job_id = str(uuid.uuid4())
await add_entity(