Fixed api issues, missing deps and got first endpoint to work
This commit is contained in:
parent
ef7d1b3bc7
commit
b2e6302ae2
2 changed files with 19 additions and 3 deletions
|
|
@ -10,7 +10,7 @@ class MemoryModel(Base):
|
||||||
|
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
user_id = Column(String, ForeignKey('users.id'), index=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)
|
memory_name = Column(String, nullable=True)
|
||||||
created_at = Column(DateTime, default=datetime.utcnow)
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
updated_at = Column(DateTime, onupdate=datetime.utcnow)
|
||||||
|
|
|
||||||
|
|
@ -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.docs import DocsModel
|
||||||
from cognitive_architecture.database.postgres.models.memory import MemoryModel
|
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
|
# Adds response_model to ChatCompletion
|
||||||
# Allows the return of Pydantic model rather than raw JSON
|
# 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):
|
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_id = str(generate_letter_uuid()) + "_" + "SEMANTICMEMORY"
|
||||||
namespace_class = namespace_id + "_class"
|
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:
|
if job_id is None:
|
||||||
job_id = str(uuid.uuid4())
|
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(
|
await add_entity(
|
||||||
session,
|
session,
|
||||||
Operation(
|
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"))
|
document_names = get_document_names(loader_settings.get("path", "None"))
|
||||||
for doc in document_names:
|
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):
|
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())
|
job_id = str(uuid.uuid4())
|
||||||
|
|
||||||
await add_entity(
|
await add_entity(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue