Prepare for the presentation, add info

This commit is contained in:
Vasilije 2024-03-08 13:09:01 +01:00
parent 5e526c0e06
commit 66b40dfcd0
6 changed files with 412 additions and 17 deletions

View file

@ -351,7 +351,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 27,
"id": "f97f11f1-4490-49ea-b193-1f858e72893b",
"metadata": {},
"outputs": [],
@ -586,7 +586,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 28,
"id": "f06edd84-c455-4034-a38b-3a7d2f746f42",
"metadata": {},
"outputs": [
@ -953,6 +953,366 @@
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Narrative Structure`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Character Identification`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Emotional Trajectories`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Thematic Elements`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Cultural and Social Context`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Temporal Aspects`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Language and Style`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Interpersonal Dynamics`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Symbolism and Metaphors`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n",
"You are a top-tier algorithm\n",
"designed for extracting information in structured formats to build a knowledge graph.\n",
"- **Nodes** represent entities and concepts. They're akin to Wikipedia nodes.\n",
"- **Edges** represent relationships between concepts. They're akin to Wikipedia links.\n",
"- The aim is to achieve simplicity and clarity in the\n",
"knowledge graph, making it accessible for a vast audience.\n",
"YOU ARE ONLY EXTRACTING DATA FOR COGNITIVE LAYER `Intertextuality`\n",
"## 2. Labeling Nodes\n",
"- **Consistency**: Ensure you use basic or elementary types for node labels.\n",
" - For example, when you identify an entity representing a person,\n",
" always label it as **\"person\"**.\n",
" Avoid using more specific terms like \"mathematician\" or \"scientist\".\n",
" - Include event, entity, time, or action nodes to the category.\n",
" - Classify the memory type as episodic or semantic.\n",
"- **Node IDs**: Never utilize integers as node IDs.\n",
" Node IDs should be names or human-readable identifiers found in the text.\n",
"## 3. Handling Numerical Data and Dates\n",
"- Numerical data, like age or other related information,\n",
"should be incorporated as attributes or properties of the respective nodes.\n",
"- **No Separate Nodes for Dates/Numbers**:\n",
"Do not create separate nodes for dates or numerical values.\n",
" Always attach them as attributes or properties of nodes.\n",
"- **Property Format**: Properties must be in a key-value format.\n",
"- **Quotation Marks**: Never use escaped single or double quotes within property values.\n",
"- **Naming Convention**: Use camelCase for property keys, e.g., `birthDate`.\n",
"## 4. Coreference Resolution\n",
"- **Maintain Entity Consistency**:\n",
"When extracting entities, it's vital to ensure consistency.\n",
"If an entity, such as \"John Doe\", is mentioned multiple times\n",
"in the text but is referred to by different names or pronouns (e.g., \"Joe\", \"he\"),\n",
"always use the most complete identifier for that entity throughout the knowledge graph.\n",
" In this example, use \"John Doe\" as the entity ID.\n",
"Remember, the knowledge graph should be coherent and easily understandable,\n",
" so maintaining consistency in entity references is crucial.\n",
"## 5. Strict Compliance\n",
"Adhere to the rules strictly. Non-compliance will result in termination\"\"\"\n"
]
}
@ -984,21 +1344,11 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": null,
"id": "4a19cc82-b892-47f3-99db-b70edccefda5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"None\n"
]
}
],
"source": [
"print(layer_1_graph)"
]
"outputs": [],
"source": []
},
{
"cell_type": "code",

View file

@ -40,7 +40,7 @@ class Config:
db_user: str = os.getenv("DB_USER", "cognee")
db_password: str = os.getenv("DB_PASSWORD", "cognee")
sqlalchemy_logging: bool = os.getenv("SQLALCHEMY_LOGGING", True)
graph_name = os.getenv("GRAPH_NAME", "cognee_graph.pkl")
graph_filename = os.getenv("GRAPH_NAME", "cognee_graph.pkl")
# Model parameters
model: str = "gpt-4-1106-preview"

View file

@ -0,0 +1,27 @@
"""Factory function to get the appropriate graph client based on the graph type."""
from typing import Type
from cognitive_architecture.config import Config
from .graph_db_interface import GraphDBInterface
from .networkx.adapter import NetworXAdapter
# Assuming Neo4jAdapter is defined somewhere
# from .neo4j.adapter import Neo4jAdapter
from enum import Enum, auto
config = Config()
config.load()
class GraphDBType(Enum):
NETWORKX = auto()
NEO4J = auto()
def get_graph_client(graph_type: GraphDBType, graph_filename: str) -> Type[GraphDBInterface]:
"""Factory function to get the appropriate graph client based on the graph type."""
if graph_filename is not None:
config.graph_filename = graph_filename
if graph_type == GraphDBType.NETWORKX:
return NetworXAdapter(filename = config.graph_filename) # Adjust as needed for NetworkX adapter configuration
elif graph_type == GraphDBType.NEO4J:
# return Neo4jAdapter(config.neo4j_config) # Uncomment and adjust as needed for Neo4j adapter configuration
raise NotImplementedError("Neo4j adapter is not implemented yet.")
else:
raise ValueError("Unsupported graph database type.")

View file

@ -5,7 +5,7 @@ import networkx as nx
from cognitive_architecture.infrastructure.databases.graph.graph_db_interface import GraphDBInterface
import logging
class NetworXDB(GraphDBInterface):
class NetworXAdapter(GraphDBInterface):
def __init__(self, filename="cognee_graph.pkl"):
self.filename = filename
self.graph = nx.MultiDiGraph()

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,17 @@
from cognitive_architecture.infrastructure.graph.get_graph_client import get_graph_client
def create_semantic_graph(
text_input: str,
filename: str,
context,
response_model: Type[BaseModel]
) -> KnowledgeGraph:
graph_type = GraphDBType.NEO4J
# Call the get_graph_client function with the selected graph type
graph_client = get_graph_client(graph_type)
GraphDBInterface