ontocast.agent¶
Agent module for OntoCast.
This module provides a collection of agents that handle various aspects of ontology processing, including document conversion, text chunking, fact aggregation, and ontology management. Each agent is designed to perform a specific task in the ontology processing pipeline.
aggregate(state, tools)
¶
Aggregate facts from multiple processed chunks into a single RDF graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
AgentState
|
Current agent state with processed chunks |
required |
tools
|
ToolBox
|
ToolBox containing aggregation tools |
required |
Returns:
| Type | Description |
|---|---|
AgentState
|
Updated agent state with aggregated facts |
Source code in ontocast/agent/aggregate_serialize.py
check_chunks_empty(state)
¶
Check if chunks are available and manage chunk processing state.
This function checks if there are remaining chunks to process and manages the state transitions accordingly. If chunks are available, it sets up the next chunk for processing. If no chunks remain, it signals completion of the workflow.
The function performs the following operations: 1. Adds the current chunk to the processed list if it exists 2. Checks if there are remaining chunks to process 3. Sets up the next chunk and resets node visits if chunks remain 4. Sets appropriate status for workflow routing
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
AgentState
|
The current agent state containing chunks and processing status. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AgentState |
AgentState
|
Updated agent state with chunk processing information. |
Example
state = AgentState(chunks=[chunk1, chunk2], current_chunk=None) updated_state = check_chunks_empty(state) print(updated_state.current_chunk) # chunk1 print(updated_state.status) # Status.FAILED
Source code in ontocast/agent/check_chunks.py
render_facts_fresh(state, tools)
async
¶
Render fresh facts from the current chunk into Turtle format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
AgentState
|
The current agent state containing the chunk to render. |
required |
tools
|
ToolBox
|
The toolbox instance providing utility functions. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AgentState |
AgentState
|
Updated state with rendered facts. |
Source code in ontocast/agent/render_facts.py
render_ontology_fresh(state, tools)
async
¶
Render ontology triples into a human-readable format.
This function takes the triples from the current ontology and renders them into a more accessible format, making the ontological knowledge easier to understand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
AgentState
|
The current agent state containing the ontology to render. |
required |
tools
|
ToolBox
|
The toolbox instance providing utility functions. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AgentState |
AgentState
|
Updated state with rendered triples. |
Source code in ontocast/agent/render_ontology.py
serialize(state, tools)
¶
Serialize the knowledge graph to the triple store.
This function: - Handles version management for updated ontologies - Tracks budget usage - Serializes both ontology and facts to the triple store
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
AgentState
|
Current agent state with ontology and facts |
required |
tools
|
ToolBox
|
ToolBox containing serialization tools |
required |
Returns:
| Type | Description |
|---|---|
AgentState
|
Updated agent state after serialization |