Skip to content

Commit

Permalink
Fixes to sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasilije1990 committed Feb 15, 2024
1 parent 14abfd0 commit 653fe04
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 41 deletions.
5 changes: 3 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ GRAPH_DB_PW =
GRAPH_DB_USER =
AWS_ACCESS_KEY_ID =
AWS_SECRET_ACCESS_KEY =
QDRANT_API_KEY
QDRANT_API_URL
QDRANT_API_KEY =
QDRANT_API_URL =
DB_TYPE = sqlite
6 changes: 3 additions & 3 deletions cognitive_architecture/database/graphdb/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
from ...llm.queries import generate_summary, generate_graph
import logging
from neo4j import AsyncGraphDatabase, Neo4jError
from neo4j import AsyncGraphDatabase
from contextlib import asynccontextmanager
from typing import Any, Dict, Optional, List

Expand Down Expand Up @@ -106,8 +106,8 @@ async def query(
async with self.get_session() as session:
result = await session.run(query, parameters=params)
return await result.data()
except Neo4jError as e:
logging.error(f"Neo4j query error: {e.message}")
except Exception as e:
logging.error(f"Neo4j query error: %s {e}")
raise

# class Neo4jGraphDB(AbstractGraphDB):
Expand Down
18 changes: 0 additions & 18 deletions cognitive_architecture/database/relationaldb/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,11 @@
load_dotenv()


# this is needed to import classes from other modules
# script_dir = os.path.dirname(os.path.abspath(__file__))
# # Get the parent directory of your script and add it to sys.path
# parent_dir = os.path.dirname(script_dir)
# sys.path.append(parent_dir)
# from ...config import Config
# config = Config()
# config.load()


# in seconds
MAX_RETRIES = 3
RETRY_DELAY = 5

import os


class DatabaseConfig:
def __init__(
self,
Expand Down Expand Up @@ -84,12 +72,6 @@ def get_sqlalchemy_database_url(self):
# config = DatabaseConfig(config_file='path/to/config.json')
# Or set them programmatically:
config = DatabaseConfig(
db_type="postgresql",
db_name="mydatabase",
user="myuser",
password="mypassword",
host="myhost",
port="5432",
)

SQLALCHEMY_DATABASE_URL = config.get_sqlalchemy_database_url()
Expand Down
2 changes: 1 addition & 1 deletion cognitive_architecture/database/vectordb/basevectordb.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import weaviate
from marshmallow import Schema, fields
import json
from vector_db_type import VectorDBType
from cognitive_architecture.database.vectordb.vector_db_type import VectorDBType


OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
Expand Down
34 changes: 17 additions & 17 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,26 +880,26 @@ class GraphQLQuery(BaseModel):
# load_doc_to_graph = await add_documents_to_graph_db(session, user_id)
# print(load_doc_to_graph)
user_id = "test_user"
# loader_settings = {
# "format": "PDF",
# "source": "DEVICE",
# "path": [".data"]
# }
# await load_documents_to_vectorstore(session, user_id, loader_settings=loader_settings)
loader_settings = {
"format": "PDF",
"source": "DEVICE",
"path": [".data"]
}
await load_documents_to_vectorstore(session, user_id, loader_settings=loader_settings)
# await create_public_memory(user_id=user_id, labels=['sr'], topic="PublicMemory")
# await add_documents_to_graph_db(session, user_id)
#
neo4j_graph_db = Neo4jGraphDB(
url=config.graph_database_url,
username=config.graph_database_username,
password=config.graph_database_password,
)

out = neo4j_graph_db.run_merge_query(
user_id=user_id, memory_type="SemanticMemory", similarity_threshold=0.5
)
bb = neo4j_graph_db.query(out)
print(bb)
# neo4j_graph_db = Neo4jGraphDB(
# url=config.graph_database_url,
# username=config.graph_database_username,
# password=config.graph_database_password,
# )
#
# out = neo4j_graph_db.run_merge_query(
# user_id=user_id, memory_type="SemanticMemory", similarity_threshold=0.5
# )
# bb = neo4j_graph_db.query(out)
# print(bb)

# await attach_user_to_memory(user_id=user_id, labels=['sr'], topic="PublicMemory")

Expand Down

0 comments on commit 653fe04

Please sign in to comment.