trustgraph-base 2.3.0__tar.gz → 2.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/PKG-INFO +1 -1
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/async_socket_client.py +4 -5
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/socket_client.py +4 -12
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/types.py +8 -8
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/agent_client.py +3 -3
- trustgraph_base-2.3.2/trustgraph/base_version.py +1 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/agent_client.py +4 -4
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/agent.py +2 -2
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/provenance/__init__.py +14 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/provenance/agent.py +141 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/provenance/namespaces.py +12 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/provenance/triples.py +33 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/provenance/uris.py +5 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/agent.py +2 -2
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph_base.egg-info/PKG-INFO +1 -1
- trustgraph_base-2.3.0/trustgraph/base_version.py +0 -1
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/README.md +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/pyproject.toml +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/setup.cfg +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/api.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/async_bulk_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/async_flow.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/async_metrics.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/bulk_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/collection.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/config.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/exceptions.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/explainability.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/flow.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/knowledge.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/library.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/api/metrics.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/agent_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/async_processor.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/backend.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/cassandra_config.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/chunking_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/collection_config_handler.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/consumer.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/consumer_spec.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/document_embeddings_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/document_embeddings_query_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/document_embeddings_store_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/dynamic_tool_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/embeddings_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/embeddings_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/flow.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/flow_processor.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/graph_embeddings_query_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/graph_embeddings_store_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/graph_rag_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/librarian_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/llm_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/logging.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/metrics.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/parameter_spec.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/producer.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/producer_spec.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/prompt_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/publisher.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/pubsub.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/pulsar_backend.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/rabbitmq_backend.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/request_response_spec.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/row_embeddings_query_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/serialization.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/spec.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/structured_query_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/subscriber.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/subscriber_spec.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/text_completion_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/tool_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/tool_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/tool_service_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/triples_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/triples_query_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/base/triples_store_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/base.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/config_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/document_embeddings_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/document_rag_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/embeddings_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/graph_rag_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/llm_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/prompt_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/row_embeddings_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/clients/triples_query_client.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/exceptions.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/knowledge/document.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/log_level.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/registry.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/base.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/collection.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/config.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/diagnosis.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/document_loading.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/embeddings.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/embeddings_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/flow.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/knowledge.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/library.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/metadata.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/nlp_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/primitives.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/prompt.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/retrieval.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/rows_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/sparql_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/structured_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/text_completion.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/tool.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/messaging/translators/triples.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/objects/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/objects/field.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/objects/object.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/provenance/vocabulary.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/rdf.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/core/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/core/metadata.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/core/primitives.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/core/topic.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/document.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/embeddings.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/graph.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/knowledge.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/nlp.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/object.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/rows.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/knowledge/structured.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/__init__.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/collection.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/config.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/diagnosis.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/flow.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/library.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/llm.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/lookup.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/nlp_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/prompt.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/retrieval.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/rows_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/sparql_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/storage.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/structured_query.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph/schema/services/tool_service.py +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph_base.egg-info/SOURCES.txt +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph_base.egg-info/requires.txt +0 -0
- {trustgraph_base-2.3.0 → trustgraph_base-2.3.2}/trustgraph_base.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trustgraph-base
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.2
|
|
4
4
|
Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
|
|
5
5
|
Author-email: "trustgraph.ai" <security@trustgraph.ai>
|
|
6
6
|
Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
|
|
@@ -178,24 +178,23 @@ class AsyncSocketClient:
|
|
|
178
178
|
|
|
179
179
|
def _parse_chunk(self, resp: Dict[str, Any]):
|
|
180
180
|
"""Parse response chunk into appropriate type. Returns None for non-content messages."""
|
|
181
|
-
chunk_type = resp.get("chunk_type")
|
|
182
181
|
message_type = resp.get("message_type")
|
|
183
182
|
|
|
184
183
|
# Handle new GraphRAG message format with message_type
|
|
185
184
|
if message_type == "provenance":
|
|
186
185
|
return None
|
|
187
186
|
|
|
188
|
-
if
|
|
187
|
+
if message_type == "thought":
|
|
189
188
|
return AgentThought(
|
|
190
189
|
content=resp.get("content", ""),
|
|
191
190
|
end_of_message=resp.get("end_of_message", False)
|
|
192
191
|
)
|
|
193
|
-
elif
|
|
192
|
+
elif message_type == "observation":
|
|
194
193
|
return AgentObservation(
|
|
195
194
|
content=resp.get("content", ""),
|
|
196
195
|
end_of_message=resp.get("end_of_message", False)
|
|
197
196
|
)
|
|
198
|
-
elif
|
|
197
|
+
elif message_type == "answer" or message_type == "final-answer":
|
|
199
198
|
return AgentAnswer(
|
|
200
199
|
content=resp.get("content", ""),
|
|
201
200
|
end_of_message=resp.get("end_of_message", False),
|
|
@@ -204,7 +203,7 @@ class AsyncSocketClient:
|
|
|
204
203
|
out_token=resp.get("out_token"),
|
|
205
204
|
model=resp.get("model"),
|
|
206
205
|
)
|
|
207
|
-
elif
|
|
206
|
+
elif message_type == "action":
|
|
208
207
|
return AgentThought(
|
|
209
208
|
content=resp.get("content", ""),
|
|
210
209
|
end_of_message=resp.get("end_of_message", False)
|
|
@@ -360,34 +360,26 @@ class SocketClient:
|
|
|
360
360
|
|
|
361
361
|
def _parse_chunk(self, resp: Dict[str, Any], include_provenance: bool = False) -> Optional[StreamingChunk]:
|
|
362
362
|
"""Parse response chunk into appropriate type. Returns None for non-content messages."""
|
|
363
|
-
chunk_type = resp.get("chunk_type")
|
|
364
363
|
message_type = resp.get("message_type")
|
|
365
364
|
|
|
366
|
-
# Handle GraphRAG/DocRAG message format with message_type
|
|
367
365
|
if message_type == "explain":
|
|
368
366
|
if include_provenance:
|
|
369
367
|
return self._build_provenance_event(resp)
|
|
370
368
|
return None
|
|
371
369
|
|
|
372
|
-
|
|
373
|
-
if chunk_type == "explain":
|
|
374
|
-
if include_provenance:
|
|
375
|
-
return self._build_provenance_event(resp)
|
|
376
|
-
return None
|
|
377
|
-
|
|
378
|
-
if chunk_type == "thought":
|
|
370
|
+
if message_type == "thought":
|
|
379
371
|
return AgentThought(
|
|
380
372
|
content=resp.get("content", ""),
|
|
381
373
|
end_of_message=resp.get("end_of_message", False),
|
|
382
374
|
message_id=resp.get("message_id", ""),
|
|
383
375
|
)
|
|
384
|
-
elif
|
|
376
|
+
elif message_type == "observation":
|
|
385
377
|
return AgentObservation(
|
|
386
378
|
content=resp.get("content", ""),
|
|
387
379
|
end_of_message=resp.get("end_of_message", False),
|
|
388
380
|
message_id=resp.get("message_id", ""),
|
|
389
381
|
)
|
|
390
|
-
elif
|
|
382
|
+
elif message_type == "answer" or message_type == "final-answer":
|
|
391
383
|
return AgentAnswer(
|
|
392
384
|
content=resp.get("content", ""),
|
|
393
385
|
end_of_message=resp.get("end_of_message", False),
|
|
@@ -397,7 +389,7 @@ class SocketClient:
|
|
|
397
389
|
out_token=resp.get("out_token"),
|
|
398
390
|
model=resp.get("model"),
|
|
399
391
|
)
|
|
400
|
-
elif
|
|
392
|
+
elif message_type == "action":
|
|
401
393
|
return AgentThought(
|
|
402
394
|
content=resp.get("content", ""),
|
|
403
395
|
end_of_message=resp.get("end_of_message", False)
|
|
@@ -149,10 +149,10 @@ class AgentThought(StreamingChunk):
|
|
|
149
149
|
Attributes:
|
|
150
150
|
content: Agent's thought text
|
|
151
151
|
end_of_message: True if this completes the current thought
|
|
152
|
-
|
|
152
|
+
message_type: Always "thought"
|
|
153
153
|
message_id: Provenance URI of the entity being built
|
|
154
154
|
"""
|
|
155
|
-
|
|
155
|
+
message_type: str = "thought"
|
|
156
156
|
message_id: str = ""
|
|
157
157
|
|
|
158
158
|
@dataclasses.dataclass
|
|
@@ -166,10 +166,10 @@ class AgentObservation(StreamingChunk):
|
|
|
166
166
|
Attributes:
|
|
167
167
|
content: Observation text describing tool results
|
|
168
168
|
end_of_message: True if this completes the current observation
|
|
169
|
-
|
|
169
|
+
message_type: Always "observation"
|
|
170
170
|
message_id: Provenance URI of the entity being built
|
|
171
171
|
"""
|
|
172
|
-
|
|
172
|
+
message_type: str = "observation"
|
|
173
173
|
message_id: str = ""
|
|
174
174
|
|
|
175
175
|
@dataclasses.dataclass
|
|
@@ -184,9 +184,9 @@ class AgentAnswer(StreamingChunk):
|
|
|
184
184
|
content: Answer text
|
|
185
185
|
end_of_message: True if this completes the current answer segment
|
|
186
186
|
end_of_dialog: True if this completes the entire agent interaction
|
|
187
|
-
|
|
187
|
+
message_type: Always "final-answer"
|
|
188
188
|
"""
|
|
189
|
-
|
|
189
|
+
message_type: str = "final-answer"
|
|
190
190
|
end_of_dialog: bool = False
|
|
191
191
|
message_id: str = ""
|
|
192
192
|
in_token: Optional[int] = None
|
|
@@ -208,9 +208,9 @@ class RAGChunk(StreamingChunk):
|
|
|
208
208
|
in_token: Input token count (populated on the final chunk, 0 otherwise)
|
|
209
209
|
out_token: Output token count (populated on the final chunk, 0 otherwise)
|
|
210
210
|
model: Model identifier (populated on the final chunk, empty otherwise)
|
|
211
|
-
|
|
211
|
+
message_type: Always "rag"
|
|
212
212
|
"""
|
|
213
|
-
|
|
213
|
+
message_type: str = "rag"
|
|
214
214
|
end_of_stream: bool = False
|
|
215
215
|
error: Optional[Dict[str, str]] = None
|
|
216
216
|
in_token: Optional[int] = None
|
|
@@ -30,19 +30,19 @@ class AgentClient(RequestResponse):
|
|
|
30
30
|
raise RuntimeError(resp.error.message)
|
|
31
31
|
|
|
32
32
|
# Handle thought chunks
|
|
33
|
-
if resp.
|
|
33
|
+
if resp.message_type == 'thought':
|
|
34
34
|
if think:
|
|
35
35
|
await think(resp.content, resp.end_of_message)
|
|
36
36
|
return False # Continue receiving
|
|
37
37
|
|
|
38
38
|
# Handle observation chunks
|
|
39
|
-
if resp.
|
|
39
|
+
if resp.message_type == 'observation':
|
|
40
40
|
if observe:
|
|
41
41
|
await observe(resp.content, resp.end_of_message)
|
|
42
42
|
return False # Continue receiving
|
|
43
43
|
|
|
44
44
|
# Handle answer chunks
|
|
45
|
-
if resp.
|
|
45
|
+
if resp.message_type == 'answer':
|
|
46
46
|
if resp.content:
|
|
47
47
|
accumulated_answer.append(resp.content)
|
|
48
48
|
if answer_callback:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.3.2"
|
|
@@ -58,23 +58,23 @@ class AgentClient(BaseClient):
|
|
|
58
58
|
|
|
59
59
|
def inspect(x):
|
|
60
60
|
# Handle errors
|
|
61
|
-
if x.
|
|
61
|
+
if x.message_type == 'error' or x.error:
|
|
62
62
|
if error_callback:
|
|
63
63
|
error_callback(x.content or (x.error.message if x.error else ""))
|
|
64
64
|
# Continue to check end_of_dialog
|
|
65
65
|
|
|
66
66
|
# Handle thought chunks
|
|
67
|
-
elif x.
|
|
67
|
+
elif x.message_type == 'thought':
|
|
68
68
|
if think:
|
|
69
69
|
think(x.content, x.end_of_message)
|
|
70
70
|
|
|
71
71
|
# Handle observation chunks
|
|
72
|
-
elif x.
|
|
72
|
+
elif x.message_type == 'observation':
|
|
73
73
|
if observe:
|
|
74
74
|
observe(x.content, x.end_of_message)
|
|
75
75
|
|
|
76
76
|
# Handle answer chunks
|
|
77
|
-
elif x.
|
|
77
|
+
elif x.message_type == 'answer':
|
|
78
78
|
if x.content:
|
|
79
79
|
accumulated_answer.append(x.content)
|
|
80
80
|
if answer_callback:
|
|
@@ -60,8 +60,8 @@ class AgentResponseTranslator(MessageTranslator):
|
|
|
60
60
|
def encode(self, obj: AgentResponse) -> Dict[str, Any]:
|
|
61
61
|
result = {}
|
|
62
62
|
|
|
63
|
-
if obj.
|
|
64
|
-
result["
|
|
63
|
+
if obj.message_type:
|
|
64
|
+
result["message_type"] = obj.message_type
|
|
65
65
|
if obj.content:
|
|
66
66
|
result["content"] = obj.content
|
|
67
67
|
result["end_of_message"] = getattr(obj, "end_of_message", False)
|
|
@@ -59,6 +59,7 @@ from . uris import (
|
|
|
59
59
|
agent_plan_uri,
|
|
60
60
|
agent_step_result_uri,
|
|
61
61
|
agent_synthesis_uri,
|
|
62
|
+
agent_pattern_decision_uri,
|
|
62
63
|
# Document RAG provenance URIs
|
|
63
64
|
docrag_question_uri,
|
|
64
65
|
docrag_grounding_uri,
|
|
@@ -102,6 +103,11 @@ from . namespaces import (
|
|
|
102
103
|
# Agent provenance predicates
|
|
103
104
|
TG_THOUGHT, TG_ACTION, TG_ARGUMENTS, TG_OBSERVATION,
|
|
104
105
|
TG_SUBAGENT_GOAL, TG_PLAN_STEP,
|
|
106
|
+
TG_TOOL_CANDIDATE, TG_TERMINATION_REASON,
|
|
107
|
+
TG_STEP_NUMBER, TG_PATTERN_DECISION, TG_PATTERN, TG_TASK_TYPE,
|
|
108
|
+
TG_LLM_DURATION_MS, TG_TOOL_DURATION_MS, TG_TOOL_ERROR,
|
|
109
|
+
TG_IN_TOKEN, TG_OUT_TOKEN,
|
|
110
|
+
TG_ERROR_TYPE,
|
|
105
111
|
# Orchestrator entity types
|
|
106
112
|
TG_DECOMPOSITION, TG_FINDING, TG_PLAN_TYPE, TG_STEP_RESULT,
|
|
107
113
|
# Document reference predicate
|
|
@@ -141,6 +147,7 @@ from . agent import (
|
|
|
141
147
|
agent_plan_triples,
|
|
142
148
|
agent_step_result_triples,
|
|
143
149
|
agent_synthesis_triples,
|
|
150
|
+
agent_pattern_decision_triples,
|
|
144
151
|
)
|
|
145
152
|
|
|
146
153
|
# Vocabulary bootstrap
|
|
@@ -182,6 +189,7 @@ __all__ = [
|
|
|
182
189
|
"agent_plan_uri",
|
|
183
190
|
"agent_step_result_uri",
|
|
184
191
|
"agent_synthesis_uri",
|
|
192
|
+
"agent_pattern_decision_uri",
|
|
185
193
|
# Document RAG provenance URIs
|
|
186
194
|
"docrag_question_uri",
|
|
187
195
|
"docrag_grounding_uri",
|
|
@@ -218,6 +226,11 @@ __all__ = [
|
|
|
218
226
|
# Agent provenance predicates
|
|
219
227
|
"TG_THOUGHT", "TG_ACTION", "TG_ARGUMENTS", "TG_OBSERVATION",
|
|
220
228
|
"TG_SUBAGENT_GOAL", "TG_PLAN_STEP",
|
|
229
|
+
"TG_TOOL_CANDIDATE", "TG_TERMINATION_REASON",
|
|
230
|
+
"TG_STEP_NUMBER", "TG_PATTERN_DECISION", "TG_PATTERN", "TG_TASK_TYPE",
|
|
231
|
+
"TG_LLM_DURATION_MS", "TG_TOOL_DURATION_MS", "TG_TOOL_ERROR",
|
|
232
|
+
"TG_IN_TOKEN", "TG_OUT_TOKEN",
|
|
233
|
+
"TG_ERROR_TYPE",
|
|
221
234
|
# Orchestrator entity types
|
|
222
235
|
"TG_DECOMPOSITION", "TG_FINDING", "TG_PLAN_TYPE", "TG_STEP_RESULT",
|
|
223
236
|
# Document reference predicate
|
|
@@ -249,6 +262,7 @@ __all__ = [
|
|
|
249
262
|
"agent_plan_triples",
|
|
250
263
|
"agent_step_result_triples",
|
|
251
264
|
"agent_synthesis_triples",
|
|
265
|
+
"agent_pattern_decision_triples",
|
|
252
266
|
# Utility
|
|
253
267
|
"set_graph",
|
|
254
268
|
# Vocabulary
|
|
@@ -29,6 +29,11 @@ from . namespaces import (
|
|
|
29
29
|
TG_AGENT_QUESTION,
|
|
30
30
|
TG_DECOMPOSITION, TG_FINDING, TG_PLAN_TYPE, TG_STEP_RESULT,
|
|
31
31
|
TG_SYNTHESIS, TG_SUBAGENT_GOAL, TG_PLAN_STEP,
|
|
32
|
+
TG_TOOL_CANDIDATE, TG_TERMINATION_REASON,
|
|
33
|
+
TG_STEP_NUMBER, TG_PATTERN_DECISION, TG_PATTERN, TG_TASK_TYPE,
|
|
34
|
+
TG_LLM_DURATION_MS, TG_TOOL_DURATION_MS, TG_TOOL_ERROR,
|
|
35
|
+
TG_ERROR_TYPE,
|
|
36
|
+
TG_IN_TOKEN, TG_OUT_TOKEN, TG_LLM_MODEL,
|
|
32
37
|
)
|
|
33
38
|
|
|
34
39
|
|
|
@@ -47,6 +52,17 @@ def _triple(s: str, p: str, o_term: Term) -> Triple:
|
|
|
47
52
|
return Triple(s=_iri(s), p=_iri(p), o=o_term)
|
|
48
53
|
|
|
49
54
|
|
|
55
|
+
def _append_token_triples(triples, uri, in_token=None, out_token=None,
|
|
56
|
+
model=None):
|
|
57
|
+
"""Append in_token/out_token/model triples when values are present."""
|
|
58
|
+
if in_token is not None:
|
|
59
|
+
triples.append(_triple(uri, TG_IN_TOKEN, _literal(str(in_token))))
|
|
60
|
+
if out_token is not None:
|
|
61
|
+
triples.append(_triple(uri, TG_OUT_TOKEN, _literal(str(out_token))))
|
|
62
|
+
if model is not None:
|
|
63
|
+
triples.append(_triple(uri, TG_LLM_MODEL, _literal(model)))
|
|
64
|
+
|
|
65
|
+
|
|
50
66
|
def agent_session_triples(
|
|
51
67
|
session_uri: str,
|
|
52
68
|
query: str,
|
|
@@ -90,6 +106,43 @@ def agent_session_triples(
|
|
|
90
106
|
return triples
|
|
91
107
|
|
|
92
108
|
|
|
109
|
+
def agent_pattern_decision_triples(
|
|
110
|
+
uri: str,
|
|
111
|
+
session_uri: str,
|
|
112
|
+
pattern: str,
|
|
113
|
+
task_type: str = "",
|
|
114
|
+
) -> List[Triple]:
|
|
115
|
+
"""
|
|
116
|
+
Build triples for a meta-router pattern decision.
|
|
117
|
+
|
|
118
|
+
Creates:
|
|
119
|
+
- Entity declaration with tg:PatternDecision type
|
|
120
|
+
- wasDerivedFrom link to session
|
|
121
|
+
- Pattern and task type predicates
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
uri: URI of this decision (from agent_pattern_decision_uri)
|
|
125
|
+
session_uri: URI of the parent session
|
|
126
|
+
pattern: Selected execution pattern (e.g. "react", "plan-then-execute")
|
|
127
|
+
task_type: Identified task type (e.g. "general", "research")
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
List of Triple objects
|
|
131
|
+
"""
|
|
132
|
+
triples = [
|
|
133
|
+
_triple(uri, RDF_TYPE, _iri(PROV_ENTITY)),
|
|
134
|
+
_triple(uri, RDF_TYPE, _iri(TG_PATTERN_DECISION)),
|
|
135
|
+
_triple(uri, RDFS_LABEL, _literal(f"Pattern: {pattern}")),
|
|
136
|
+
_triple(uri, TG_PATTERN, _literal(pattern)),
|
|
137
|
+
_triple(uri, PROV_WAS_DERIVED_FROM, _iri(session_uri)),
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
if task_type:
|
|
141
|
+
triples.append(_triple(uri, TG_TASK_TYPE, _literal(task_type)))
|
|
142
|
+
|
|
143
|
+
return triples
|
|
144
|
+
|
|
145
|
+
|
|
93
146
|
def agent_iteration_triples(
|
|
94
147
|
iteration_uri: str,
|
|
95
148
|
question_uri: Optional[str] = None,
|
|
@@ -98,6 +151,12 @@ def agent_iteration_triples(
|
|
|
98
151
|
arguments: Dict[str, Any] = None,
|
|
99
152
|
thought_uri: Optional[str] = None,
|
|
100
153
|
thought_document_id: Optional[str] = None,
|
|
154
|
+
tool_candidates: Optional[List[str]] = None,
|
|
155
|
+
step_number: Optional[int] = None,
|
|
156
|
+
llm_duration_ms: Optional[int] = None,
|
|
157
|
+
in_token: Optional[int] = None,
|
|
158
|
+
out_token: Optional[int] = None,
|
|
159
|
+
model: Optional[str] = None,
|
|
101
160
|
) -> List[Triple]:
|
|
102
161
|
"""
|
|
103
162
|
Build triples for one agent iteration (Analysis+ToolUse).
|
|
@@ -106,6 +165,7 @@ def agent_iteration_triples(
|
|
|
106
165
|
- Entity declaration with tg:Analysis and tg:ToolUse types
|
|
107
166
|
- wasDerivedFrom link to question (if first iteration) or previous
|
|
108
167
|
- Action and arguments metadata
|
|
168
|
+
- Tool candidates (names of tools visible to the LLM)
|
|
109
169
|
- Thought sub-entity (tg:Reflection, tg:Thought) with librarian document
|
|
110
170
|
|
|
111
171
|
Args:
|
|
@@ -116,6 +176,7 @@ def agent_iteration_triples(
|
|
|
116
176
|
arguments: Arguments passed to the tool (will be JSON-encoded)
|
|
117
177
|
thought_uri: URI for the thought sub-entity
|
|
118
178
|
thought_document_id: Document URI for thought in librarian
|
|
179
|
+
tool_candidates: List of tool names available to the LLM
|
|
119
180
|
|
|
120
181
|
Returns:
|
|
121
182
|
List of Triple objects
|
|
@@ -132,6 +193,23 @@ def agent_iteration_triples(
|
|
|
132
193
|
_triple(iteration_uri, TG_ARGUMENTS, _literal(json.dumps(arguments))),
|
|
133
194
|
]
|
|
134
195
|
|
|
196
|
+
if tool_candidates:
|
|
197
|
+
for name in tool_candidates:
|
|
198
|
+
triples.append(
|
|
199
|
+
_triple(iteration_uri, TG_TOOL_CANDIDATE, _literal(name))
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
if step_number is not None:
|
|
203
|
+
triples.append(
|
|
204
|
+
_triple(iteration_uri, TG_STEP_NUMBER, _literal(str(step_number)))
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
if llm_duration_ms is not None:
|
|
208
|
+
triples.append(
|
|
209
|
+
_triple(iteration_uri, TG_LLM_DURATION_MS,
|
|
210
|
+
_literal(str(llm_duration_ms)))
|
|
211
|
+
)
|
|
212
|
+
|
|
135
213
|
if question_uri:
|
|
136
214
|
triples.append(
|
|
137
215
|
_triple(iteration_uri, PROV_WAS_DERIVED_FROM, _iri(question_uri))
|
|
@@ -155,6 +233,8 @@ def agent_iteration_triples(
|
|
|
155
233
|
_triple(thought_uri, TG_DOCUMENT, _iri(thought_document_id))
|
|
156
234
|
)
|
|
157
235
|
|
|
236
|
+
_append_token_triples(triples, iteration_uri, in_token, out_token, model)
|
|
237
|
+
|
|
158
238
|
return triples
|
|
159
239
|
|
|
160
240
|
|
|
@@ -162,6 +242,8 @@ def agent_observation_triples(
|
|
|
162
242
|
observation_uri: str,
|
|
163
243
|
iteration_uri: str,
|
|
164
244
|
document_id: Optional[str] = None,
|
|
245
|
+
tool_duration_ms: Optional[int] = None,
|
|
246
|
+
tool_error: Optional[str] = None,
|
|
165
247
|
) -> List[Triple]:
|
|
166
248
|
"""
|
|
167
249
|
Build triples for an agent observation (standalone entity).
|
|
@@ -170,11 +252,15 @@ def agent_observation_triples(
|
|
|
170
252
|
- Entity declaration with prov:Entity and tg:Observation types
|
|
171
253
|
- wasDerivedFrom link to the iteration (Analysis+ToolUse)
|
|
172
254
|
- Document reference to librarian (if provided)
|
|
255
|
+
- Tool execution duration (if provided)
|
|
256
|
+
- Tool error message (if the tool failed)
|
|
173
257
|
|
|
174
258
|
Args:
|
|
175
259
|
observation_uri: URI of the observation entity
|
|
176
260
|
iteration_uri: URI of the iteration this observation derives from
|
|
177
261
|
document_id: Librarian document ID for the observation content
|
|
262
|
+
tool_duration_ms: Tool execution time in milliseconds
|
|
263
|
+
tool_error: Error message if the tool failed
|
|
178
264
|
|
|
179
265
|
Returns:
|
|
180
266
|
List of Triple objects
|
|
@@ -191,6 +277,20 @@ def agent_observation_triples(
|
|
|
191
277
|
_triple(observation_uri, TG_DOCUMENT, _iri(document_id))
|
|
192
278
|
)
|
|
193
279
|
|
|
280
|
+
if tool_duration_ms is not None:
|
|
281
|
+
triples.append(
|
|
282
|
+
_triple(observation_uri, TG_TOOL_DURATION_MS,
|
|
283
|
+
_literal(str(tool_duration_ms)))
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
if tool_error:
|
|
287
|
+
triples.append(
|
|
288
|
+
_triple(observation_uri, TG_TOOL_ERROR, _literal(tool_error))
|
|
289
|
+
)
|
|
290
|
+
triples.append(
|
|
291
|
+
_triple(observation_uri, RDF_TYPE, _iri(TG_ERROR_TYPE))
|
|
292
|
+
)
|
|
293
|
+
|
|
194
294
|
return triples
|
|
195
295
|
|
|
196
296
|
|
|
@@ -199,6 +299,10 @@ def agent_final_triples(
|
|
|
199
299
|
question_uri: Optional[str] = None,
|
|
200
300
|
previous_uri: Optional[str] = None,
|
|
201
301
|
document_id: Optional[str] = None,
|
|
302
|
+
termination_reason: Optional[str] = None,
|
|
303
|
+
in_token: Optional[int] = None,
|
|
304
|
+
out_token: Optional[int] = None,
|
|
305
|
+
model: Optional[str] = None,
|
|
202
306
|
) -> List[Triple]:
|
|
203
307
|
"""
|
|
204
308
|
Build triples for an agent final answer (Conclusion).
|
|
@@ -208,12 +312,15 @@ def agent_final_triples(
|
|
|
208
312
|
- wasGeneratedBy link to question (if no iterations)
|
|
209
313
|
- wasDerivedFrom link to last iteration (if iterations exist)
|
|
210
314
|
- Document reference to librarian
|
|
315
|
+
- Termination reason (why the agent loop stopped)
|
|
211
316
|
|
|
212
317
|
Args:
|
|
213
318
|
final_uri: URI of the final answer (from agent_final_uri)
|
|
214
319
|
question_uri: URI of the question activity (if no iterations)
|
|
215
320
|
previous_uri: URI of the last iteration (if iterations exist)
|
|
216
321
|
document_id: Librarian document ID for the answer content
|
|
322
|
+
termination_reason: Why the loop stopped, e.g. "final-answer",
|
|
323
|
+
"max-iterations", "error"
|
|
217
324
|
|
|
218
325
|
Returns:
|
|
219
326
|
List of Triple objects
|
|
@@ -237,6 +344,14 @@ def agent_final_triples(
|
|
|
237
344
|
if document_id:
|
|
238
345
|
triples.append(_triple(final_uri, TG_DOCUMENT, _iri(document_id)))
|
|
239
346
|
|
|
347
|
+
if termination_reason:
|
|
348
|
+
triples.append(
|
|
349
|
+
_triple(final_uri, TG_TERMINATION_REASON,
|
|
350
|
+
_literal(termination_reason))
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
_append_token_triples(triples, final_uri, in_token, out_token, model)
|
|
354
|
+
|
|
240
355
|
return triples
|
|
241
356
|
|
|
242
357
|
|
|
@@ -244,6 +359,9 @@ def agent_decomposition_triples(
|
|
|
244
359
|
uri: str,
|
|
245
360
|
session_uri: str,
|
|
246
361
|
goals: List[str],
|
|
362
|
+
in_token: Optional[int] = None,
|
|
363
|
+
out_token: Optional[int] = None,
|
|
364
|
+
model: Optional[str] = None,
|
|
247
365
|
) -> List[Triple]:
|
|
248
366
|
"""Build triples for a supervisor decomposition step."""
|
|
249
367
|
triples = [
|
|
@@ -255,6 +373,7 @@ def agent_decomposition_triples(
|
|
|
255
373
|
]
|
|
256
374
|
for goal in goals:
|
|
257
375
|
triples.append(_triple(uri, TG_SUBAGENT_GOAL, _literal(goal)))
|
|
376
|
+
_append_token_triples(triples, uri, in_token, out_token, model)
|
|
258
377
|
return triples
|
|
259
378
|
|
|
260
379
|
|
|
@@ -282,6 +401,9 @@ def agent_plan_triples(
|
|
|
282
401
|
uri: str,
|
|
283
402
|
session_uri: str,
|
|
284
403
|
steps: List[str],
|
|
404
|
+
in_token: Optional[int] = None,
|
|
405
|
+
out_token: Optional[int] = None,
|
|
406
|
+
model: Optional[str] = None,
|
|
285
407
|
) -> List[Triple]:
|
|
286
408
|
"""Build triples for a plan-then-execute plan."""
|
|
287
409
|
triples = [
|
|
@@ -293,6 +415,7 @@ def agent_plan_triples(
|
|
|
293
415
|
]
|
|
294
416
|
for step in steps:
|
|
295
417
|
triples.append(_triple(uri, TG_PLAN_STEP, _literal(step)))
|
|
418
|
+
_append_token_triples(triples, uri, in_token, out_token, model)
|
|
296
419
|
return triples
|
|
297
420
|
|
|
298
421
|
|
|
@@ -301,6 +424,9 @@ def agent_step_result_triples(
|
|
|
301
424
|
plan_uri: str,
|
|
302
425
|
goal: str,
|
|
303
426
|
document_id: Optional[str] = None,
|
|
427
|
+
in_token: Optional[int] = None,
|
|
428
|
+
out_token: Optional[int] = None,
|
|
429
|
+
model: Optional[str] = None,
|
|
304
430
|
) -> List[Triple]:
|
|
305
431
|
"""Build triples for a plan step result."""
|
|
306
432
|
triples = [
|
|
@@ -313,6 +439,7 @@ def agent_step_result_triples(
|
|
|
313
439
|
]
|
|
314
440
|
if document_id:
|
|
315
441
|
triples.append(_triple(uri, TG_DOCUMENT, _iri(document_id)))
|
|
442
|
+
_append_token_triples(triples, uri, in_token, out_token, model)
|
|
316
443
|
return triples
|
|
317
444
|
|
|
318
445
|
|
|
@@ -320,6 +447,10 @@ def agent_synthesis_triples(
|
|
|
320
447
|
uri: str,
|
|
321
448
|
previous_uris,
|
|
322
449
|
document_id: Optional[str] = None,
|
|
450
|
+
termination_reason: Optional[str] = None,
|
|
451
|
+
in_token: Optional[int] = None,
|
|
452
|
+
out_token: Optional[int] = None,
|
|
453
|
+
model: Optional[str] = None,
|
|
323
454
|
) -> List[Triple]:
|
|
324
455
|
"""Build triples for a synthesis answer.
|
|
325
456
|
|
|
@@ -327,6 +458,8 @@ def agent_synthesis_triples(
|
|
|
327
458
|
uri: URI of the synthesis entity
|
|
328
459
|
previous_uris: Single URI string or list of URIs to derive from
|
|
329
460
|
document_id: Librarian document ID for the answer content
|
|
461
|
+
termination_reason: Why the agent loop stopped
|
|
462
|
+
in_token/out_token/model: Token usage for the synthesis LLM call
|
|
330
463
|
"""
|
|
331
464
|
triples = [
|
|
332
465
|
_triple(uri, RDF_TYPE, _iri(PROV_ENTITY)),
|
|
@@ -342,4 +475,12 @@ def agent_synthesis_triples(
|
|
|
342
475
|
|
|
343
476
|
if document_id:
|
|
344
477
|
triples.append(_triple(uri, TG_DOCUMENT, _iri(document_id)))
|
|
478
|
+
|
|
479
|
+
if termination_reason:
|
|
480
|
+
triples.append(
|
|
481
|
+
_triple(uri, TG_TERMINATION_REASON, _literal(termination_reason))
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
_append_token_triples(triples, uri, in_token, out_token, model)
|
|
485
|
+
|
|
345
486
|
return triples
|
|
@@ -119,6 +119,18 @@ TG_ARGUMENTS = TG + "arguments"
|
|
|
119
119
|
TG_OBSERVATION = TG + "observation" # Links iteration to observation sub-entity
|
|
120
120
|
TG_SUBAGENT_GOAL = TG + "subagentGoal" # Goal string on Decomposition/Finding
|
|
121
121
|
TG_PLAN_STEP = TG + "planStep" # Step goal string on Plan/StepResult
|
|
122
|
+
TG_TOOL_CANDIDATE = TG + "toolCandidate" # Tool name on Analysis events
|
|
123
|
+
TG_TERMINATION_REASON = TG + "terminationReason" # Why the agent loop stopped
|
|
124
|
+
TG_STEP_NUMBER = TG + "stepNumber" # Explicit step counter on iteration events
|
|
125
|
+
TG_PATTERN_DECISION = TG + "PatternDecision" # Meta-router routing decision entity type
|
|
126
|
+
TG_PATTERN = TG + "pattern" # Selected execution pattern
|
|
127
|
+
TG_TASK_TYPE = TG + "taskType" # Identified task type
|
|
128
|
+
TG_LLM_DURATION_MS = TG + "llmDurationMs" # LLM call duration in milliseconds
|
|
129
|
+
TG_TOOL_DURATION_MS = TG + "toolDurationMs" # Tool execution duration in milliseconds
|
|
130
|
+
TG_TOOL_ERROR = TG + "toolError" # Error message from a failed tool execution
|
|
131
|
+
TG_ERROR_TYPE = TG + "Error" # Mixin type for failure events
|
|
132
|
+
TG_IN_TOKEN = TG + "inToken" # Input token count for an LLM call
|
|
133
|
+
TG_OUT_TOKEN = TG + "outToken" # Output token count for an LLM call
|
|
122
134
|
|
|
123
135
|
# Named graph URIs for RDF datasets
|
|
124
136
|
# These separate different types of data while keeping them in the same collection
|