KnowledgeBase class is the primary interface for working with a1facts. It encapsulates the ontology, the knowledge graph, and the knowledge acquirer, providing a unified access point to all the functionalities of the framework.
To get started, you need to create an instance of the KnowledgeBase class, which requires configuration files for the ontology and knowledge sources.
__init__
Initializes a new instance of the KnowledgeBase class.
Parameters
The name of the knowledge base.
The path to the ontology configuration file.
The path to the knowledge sources configuration file.
If
True, the knowledge base will use a Neo4j backend. Otherwise, it will use an in-memory graph.If
True, the knowledge base will not use Exa search for knowledge acquisition.query
Executes a query against the knowledge graph to retrieve information.
Parameters
The query to execute against the knowledge graph.
Returns
The result of the query from the knowledge graph.
ingest_knowledge
Ingests and integrates a string of new knowledge into the knowledge graph.
Parameters
The knowledge to be ingested into the knowledge graph.
Returns
The result of the knowledge ingestion operation.
acquire_knowledge_for_query
Acquires new knowledge from configured sources based on a query and integrates it into the knowledge graph.
Parameters
The query to guide the knowledge acquisition process.
Returns
The newly acquired knowledge.
get_tools
Returns a list of tools that can be used by an AI agent to interact with the knowledge base. These tools allow the agent to query for information and acquire new knowledge.
Returns
A list containing two tool functions:
query_tool and acquire_tool.query_tool
The query_tool allows an agent to retrieve precise information from the knowledge graph by translating a natural language query into a graph traversal.
Parameters
The natural language query to execute against the knowledge graph.
The result of the query from the knowledge graph. The type of the result will depend on the query.
acquire_tool
The acquire_tool enables an agent to ingest new information into the knowledge graph from the configured knowledge sources. It takes a query, fetches relevant data, and updates the graph according to the ontology.
Parameters
The query to send to the knowledge acquirer. This will guide the data ingestion process.
The result from the knowledge acquirer, which may include a summary of the ingested data.