add_coginitive_layer_graphs fix

This commit is contained in:
vujke 2024-06-01 18:43:04 +02:00
parent 11c5cf071e
commit b5c6628cfe
2 changed files with 13 additions and 7 deletions

View file

@ -1,9 +1,11 @@
""" This module contains the configuration for the graph database. """ """ This module contains the configuration for the graph database. """
import os import os
from functools import lru_cache from functools import lru_cache
from pydantic_settings import BaseSettings, SettingsConfigDict from pydantic_settings import BaseSettings, SettingsConfigDict
from cognee.infrastructure.databases.relational.config import get_relationaldb_config from cognee.infrastructure.databases.relational.config import get_relationaldb_config
from cognee.shared.data_models import DefaultGraphModel, GraphDBType from cognee.shared.data_models import DefaultGraphModel, GraphDBType, KnowledgeGraph
class GraphConfig(BaseSettings): class GraphConfig(BaseSettings):
graph_filename: str = "cognee_graph.pkl" graph_filename: str = "cognee_graph.pkl"
@ -12,11 +14,13 @@ class GraphConfig(BaseSettings):
graph_database_username: str = "" graph_database_username: str = ""
graph_database_password: str = "" graph_database_password: str = ""
graph_database_port: int = 123 graph_database_port: int = 123
graph_file_path: str = os.path.join(get_relationaldb_config().db_path, graph_filename) graph_file_path: str = os.path.join(
graph_engine: object = GraphDBType.NETWORKX get_relationaldb_config().db_path, graph_filename
graph_model: object = DefaultGraphModel )
graph_engine: object = GraphDBType.NETWORKX
graph_model: object = KnowledgeGraph
model_config = SettingsConfigDict(env_file = ".env", extra = "allow") model_config = SettingsConfigDict(env_file=".env", extra="allow")
def to_dict(self) -> dict: def to_dict(self) -> dict:
return { return {
@ -28,10 +32,10 @@ class GraphConfig(BaseSettings):
"graph_database_username": self.graph_database_username, "graph_database_username": self.graph_database_username,
"graph_database_password": self.graph_database_password, "graph_database_password": self.graph_database_password,
"graph_database_port": self.graph_database_port, "graph_database_port": self.graph_database_port,
"graph_engine": self.graph_engine "graph_engine": self.graph_engine,
} }
@lru_cache @lru_cache
def get_graph_config(): def get_graph_config():
return GraphConfig() return GraphConfig()

View file

@ -3,10 +3,12 @@ from uuid import uuid4
from typing import List, Tuple, TypedDict from typing import List, Tuple, TypedDict
from pydantic import BaseModel from pydantic import BaseModel
from cognee.infrastructure.databases.vector import DataPoint from cognee.infrastructure.databases.vector import DataPoint
# from cognee.utils import extract_pos_tags, extract_named_entities, extract_sentiment_vader # from cognee.utils import extract_pos_tags, extract_named_entities, extract_sentiment_vader
from cognee.infrastructure.databases.graph.config import get_graph_config from cognee.infrastructure.databases.graph.config import get_graph_config
from cognee.infrastructure.databases.vector.config import get_vectordb_config from cognee.infrastructure.databases.vector.config import get_vectordb_config
class GraphLike(TypedDict): class GraphLike(TypedDict):
nodes: List nodes: List
edges: List edges: List