Skip to main content
The KnowledgeGraph class is responsible for adding, updating, and querying entities and relationships in the graph database, based on a provided ontology.

__init__(self, ontology: KnowledgeOntology, use_neo4j: bool = False)

Initializes a new instance of the KnowledgeGraph class.
Parameters:
  • ontology (KnowledgeOntology): The ontology defining the graph’s structure.
  • use_neo4j (bool, optional): Whether to use Neo4j as the backend. Defaults to False.

query(self, query: str)

Executes a natural language query against the knowledge graph.
Parameters:
  • query (str): The natural language query to execute.
Returns:
  • The content of the agent’s response as a string.

update_knowledge(self, knowledge: str)

Updates the knowledge graph with new, unstructured information.
Parameters:
  • knowledge (str): A string of unstructured knowledge to add to the graph.
Returns:
  • The content of the agent’s response as a string.

close(self)

Closes the connection to the graph database.