Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ontocast/agent/check_chunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def check_chunks_empty(state: AgentState) -> AgentState:
state.current_chunk = state.chunks.pop(0)
state.node_visits = defaultdict(int)
state.status = Status.FAILED
# TODO use method for easier tracing
else:
state.current_chunk = Chunk(
text="",
Expand Down
14 changes: 9 additions & 5 deletions ontocast/onto/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
from pydantic import ConfigDict, Field

from ontocast.onto.chunk import Chunk
from ontocast.onto.constants import (
CHUNK_NULL_IRI,
DEFAULT_DOMAIN,
ONTOLOGY_NULL_IRI,
)
from ontocast.onto.constants import CHUNK_NULL_IRI, DEFAULT_DOMAIN, ONTOLOGY_NULL_IRI
from ontocast.onto.context import AgentContext, AgentType, ContextManager
from ontocast.onto.enum import FailureStage, Status, WorkflowNode
from ontocast.onto.model import BasePydanticModel, Suggestions
Expand Down Expand Up @@ -167,6 +163,8 @@ class AgentState(BasePydanticModel):
default=None,
)

graph_uri_override: str | None = Field(default=None)

source_url: str | None = Field(
description="Source URL from JSON input file (for provenance tracking)",
default=None,
Expand Down Expand Up @@ -578,6 +576,12 @@ def doc_namespace(self):
"""
return iri2namespace(self.doc_iri, ontology=False)

@property
def graph_uri(self):
if self.graph_uri_override is not None:
return self.graph_uri_override
return self.doc_namespace

@property
def ontology_id(self):
"""Get the document namespace.
Expand Down
8 changes: 3 additions & 5 deletions ontocast/toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
from ontocast.tool.llm import LLMTool
from ontocast.tool.ontology_manager import OntologyManager
from ontocast.tool.sparql import SPARQLTool
from ontocast.tool.triple_manager.core import (
TripleStoreManager,
)
from ontocast.tool.triple_manager.core import TripleStoreManager

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -193,7 +191,7 @@ def serialize(self, state: AgentState) -> None:
self.filesystem_manager.serialize(state.current_ontology)
self.filesystem_manager.serialize(
state.aggregated_facts,
graph_uri=state.doc_namespace,
graph_uri=state.graph_uri,
)
if (
self.triple_store_manager is not None
Expand All @@ -203,7 +201,7 @@ def serialize(self, state: AgentState) -> None:
self.triple_store_manager.serialize(state.current_ontology)
self.triple_store_manager.serialize(
state.aggregated_facts,
graph_uri=state.doc_namespace,
graph_uri=state.graph_uri,
)

async def initialize(self) -> None:
Expand Down