cognee/cognee/modules/data/get_layer_graphs.py
Vasilije bb679c2dd7
Improve processing, update networkx client, and Neo4j, and dspy (#69)
* Update cognify and the networkx client to prepare for running in Neo4j

* Fix for openai model

* Add the fix to the infra so that the models can be passed to the library. Enable llm_provider to be passed.

* Auto graph generation now works with neo4j

* Added fixes for both neo4j and networkx

* Explicitly name semantic node connections

* Added updated docs, readme, chunkers and updates to cognify

* Make docs build trigger only when changes on it happen

* Update docs, test git actions

* Separate cognify logic into tasks

* Introduce dspy knowledge graph extraction

---------
Co-authored-by: Boris Arzentar <borisarzentar@gmail.com>
2024-04-20 19:05:40 +02:00

23 lines
895 B
Python

import logging
import asyncio
from cognee.infrastructure import infrastructure_config
from .extraction.knowledge_graph.extract_knowledge_graph import extract_knowledge_graph
logger = logging.getLogger(__name__)
async def get_layer_graphs(content: str, cognitive_layers: list[tuple[str, dict]]):
try:
graph_awaitables = [
extract_knowledge_graph(
content,
cognitive_layer_data["name"],
infrastructure_config.get_config()["graph_model"]
) for (_, cognitive_layer_data) in cognitive_layers
]
graphs = await asyncio.gather(*graph_awaitables)
return [(layer_id, graphs[layer_index]) for (layer_index, (layer_id, __)) in enumerate(cognitive_layers)]
except Exception as error:
logger.error("Error extracting graph from content: %s", error, exc_info = True)
raise error