trustgraph-base 2.2.10__tar.gz → 2.2.11__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.2.10 → trustgraph_base-2.2.11}/PKG-INFO +1 -1
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/__init__.py +4 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/explainability.py +151 -50
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/prompt_client.py +3 -20
- trustgraph_base-2.2.11/trustgraph/base_version.py +1 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/provenance/__init__.py +30 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/provenance/agent.py +104 -3
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/provenance/namespaces.py +9 -1
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/provenance/uris.py +25 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/provenance/vocabulary.py +8 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph_base.egg-info/PKG-INFO +1 -1
- trustgraph_base-2.2.10/trustgraph/base_version.py +0 -1
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/README.md +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/pyproject.toml +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/setup.cfg +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/api.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/async_bulk_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/async_flow.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/async_metrics.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/async_socket_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/bulk_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/collection.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/config.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/exceptions.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/flow.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/knowledge.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/library.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/metrics.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/socket_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/api/types.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/agent_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/agent_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/async_processor.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/backend.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/cassandra_config.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/chunking_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/collection_config_handler.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/consumer.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/consumer_spec.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/document_embeddings_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/document_embeddings_query_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/document_embeddings_store_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/dynamic_tool_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/embeddings_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/embeddings_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/flow.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/flow_processor.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/graph_embeddings_query_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/graph_embeddings_store_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/graph_rag_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/llm_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/logging.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/metrics.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/parameter_spec.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/producer.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/producer_spec.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/publisher.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/pubsub.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/pulsar_backend.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/request_response_spec.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/row_embeddings_query_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/spec.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/structured_query_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/subscriber.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/subscriber_spec.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/text_completion_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/tool_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/tool_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/tool_service_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/triples_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/triples_query_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/base/triples_store_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/agent_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/base.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/config_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/document_embeddings_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/document_rag_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/embeddings_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/graph_rag_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/llm_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/prompt_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/row_embeddings_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/clients/triples_query_client.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/exceptions.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/knowledge/document.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/log_level.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/registry.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/agent.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/base.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/collection.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/config.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/diagnosis.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/document_loading.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/embeddings.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/embeddings_query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/flow.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/knowledge.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/library.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/metadata.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/nlp_query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/primitives.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/prompt.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/retrieval.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/rows_query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/structured_query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/text_completion.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/tool.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/messaging/translators/triples.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/objects/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/objects/field.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/objects/object.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/provenance/triples.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/rdf.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/core/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/core/metadata.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/core/primitives.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/core/topic.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/document.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/embeddings.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/graph.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/knowledge.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/nlp.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/object.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/rows.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/knowledge/structured.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/__init__.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/agent.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/collection.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/config.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/diagnosis.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/flow.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/library.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/llm.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/lookup.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/nlp_query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/prompt.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/retrieval.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/rows_query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/storage.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/structured_query.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph/schema/services/tool_service.py +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph_base.egg-info/SOURCES.txt +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/trustgraph_base.egg-info/requires.txt +0 -0
- {trustgraph_base-2.2.10 → trustgraph_base-2.2.11}/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.2.
|
|
3
|
+
Version: 2.2.11
|
|
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
|
|
@@ -44,6 +44,16 @@ TG_GRAPH_RAG_QUESTION = TG + "GraphRagQuestion"
|
|
|
44
44
|
TG_DOC_RAG_QUESTION = TG + "DocRagQuestion"
|
|
45
45
|
TG_AGENT_QUESTION = TG + "AgentQuestion"
|
|
46
46
|
|
|
47
|
+
# Orchestrator entity types
|
|
48
|
+
TG_DECOMPOSITION = TG + "Decomposition"
|
|
49
|
+
TG_FINDING = TG + "Finding"
|
|
50
|
+
TG_PLAN_TYPE = TG + "Plan"
|
|
51
|
+
TG_STEP_RESULT = TG + "StepResult"
|
|
52
|
+
|
|
53
|
+
# Orchestrator predicates
|
|
54
|
+
TG_SUBAGENT_GOAL = TG + "subagentGoal"
|
|
55
|
+
TG_PLAN_STEP = TG + "planStep"
|
|
56
|
+
|
|
47
57
|
# PROV-O predicates
|
|
48
58
|
PROV = "http://www.w3.org/ns/prov#"
|
|
49
59
|
PROV_STARTED_AT_TIME = PROV + "startedAtTime"
|
|
@@ -82,6 +92,14 @@ class ExplainEntity:
|
|
|
82
92
|
return Exploration.from_triples(uri, triples)
|
|
83
93
|
elif TG_FOCUS in types:
|
|
84
94
|
return Focus.from_triples(uri, triples)
|
|
95
|
+
elif TG_DECOMPOSITION in types:
|
|
96
|
+
return Decomposition.from_triples(uri, triples)
|
|
97
|
+
elif TG_FINDING in types:
|
|
98
|
+
return Finding.from_triples(uri, triples)
|
|
99
|
+
elif TG_PLAN_TYPE in types:
|
|
100
|
+
return Plan.from_triples(uri, triples)
|
|
101
|
+
elif TG_STEP_RESULT in types:
|
|
102
|
+
return StepResult.from_triples(uri, triples)
|
|
85
103
|
elif TG_SYNTHESIS in types:
|
|
86
104
|
return Synthesis.from_triples(uri, triples)
|
|
87
105
|
elif TG_REFLECTION_TYPE in types:
|
|
@@ -314,6 +332,70 @@ class Conclusion(ExplainEntity):
|
|
|
314
332
|
)
|
|
315
333
|
|
|
316
334
|
|
|
335
|
+
@dataclass
|
|
336
|
+
class Decomposition(ExplainEntity):
|
|
337
|
+
"""Decomposition entity - supervisor broke question into sub-goals."""
|
|
338
|
+
goals: List[str] = field(default_factory=list)
|
|
339
|
+
|
|
340
|
+
@classmethod
|
|
341
|
+
def from_triples(cls, uri: str, triples: List[Tuple[str, str, Any]]) -> "Decomposition":
|
|
342
|
+
goals = []
|
|
343
|
+
for s, p, o in triples:
|
|
344
|
+
if p == TG_SUBAGENT_GOAL:
|
|
345
|
+
goals.append(o)
|
|
346
|
+
return cls(uri=uri, entity_type="decomposition", goals=goals)
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
@dataclass
|
|
350
|
+
class Finding(ExplainEntity):
|
|
351
|
+
"""Finding entity - a subagent's result."""
|
|
352
|
+
goal: str = ""
|
|
353
|
+
document: str = ""
|
|
354
|
+
|
|
355
|
+
@classmethod
|
|
356
|
+
def from_triples(cls, uri: str, triples: List[Tuple[str, str, Any]]) -> "Finding":
|
|
357
|
+
goal = ""
|
|
358
|
+
document = ""
|
|
359
|
+
for s, p, o in triples:
|
|
360
|
+
if p == TG_SUBAGENT_GOAL:
|
|
361
|
+
goal = o
|
|
362
|
+
elif p == TG_DOCUMENT:
|
|
363
|
+
document = o
|
|
364
|
+
return cls(uri=uri, entity_type="finding", goal=goal, document=document)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
@dataclass
|
|
368
|
+
class Plan(ExplainEntity):
|
|
369
|
+
"""Plan entity - a structured plan of steps."""
|
|
370
|
+
steps: List[str] = field(default_factory=list)
|
|
371
|
+
|
|
372
|
+
@classmethod
|
|
373
|
+
def from_triples(cls, uri: str, triples: List[Tuple[str, str, Any]]) -> "Plan":
|
|
374
|
+
steps = []
|
|
375
|
+
for s, p, o in triples:
|
|
376
|
+
if p == TG_PLAN_STEP:
|
|
377
|
+
steps.append(o)
|
|
378
|
+
return cls(uri=uri, entity_type="plan", steps=steps)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
@dataclass
|
|
382
|
+
class StepResult(ExplainEntity):
|
|
383
|
+
"""StepResult entity - a plan step's result."""
|
|
384
|
+
step: str = ""
|
|
385
|
+
document: str = ""
|
|
386
|
+
|
|
387
|
+
@classmethod
|
|
388
|
+
def from_triples(cls, uri: str, triples: List[Tuple[str, str, Any]]) -> "StepResult":
|
|
389
|
+
step = ""
|
|
390
|
+
document = ""
|
|
391
|
+
for s, p, o in triples:
|
|
392
|
+
if p == TG_PLAN_STEP:
|
|
393
|
+
step = o
|
|
394
|
+
elif p == TG_DOCUMENT:
|
|
395
|
+
document = o
|
|
396
|
+
return cls(uri=uri, entity_type="step-result", step=step, document=document)
|
|
397
|
+
|
|
398
|
+
|
|
317
399
|
def parse_edge_selection_triples(triples: List[Tuple[str, str, Any]]) -> EdgeSelection:
|
|
318
400
|
"""Parse triples for an edge selection entity."""
|
|
319
401
|
uri = triples[0][0] if triples else ""
|
|
@@ -895,7 +977,10 @@ class ExplainabilityClient:
|
|
|
895
977
|
"""
|
|
896
978
|
Fetch the complete Agent trace starting from a session URI.
|
|
897
979
|
|
|
898
|
-
Follows the provenance chain
|
|
980
|
+
Follows the provenance chain for all patterns:
|
|
981
|
+
- ReAct: Question -> Analysis(s) -> Conclusion
|
|
982
|
+
- Supervisor: Question -> Decomposition -> Finding(s) -> Synthesis
|
|
983
|
+
- Plan-then-Execute: Question -> Plan -> StepResult(s) -> Synthesis
|
|
899
984
|
|
|
900
985
|
Args:
|
|
901
986
|
session_uri: The agent session/question URI
|
|
@@ -906,14 +991,15 @@ class ExplainabilityClient:
|
|
|
906
991
|
max_content: Maximum content length for conclusion
|
|
907
992
|
|
|
908
993
|
Returns:
|
|
909
|
-
Dict with question,
|
|
994
|
+
Dict with question, steps (mixed entity list), conclusion/synthesis
|
|
910
995
|
"""
|
|
911
996
|
if graph is None:
|
|
912
997
|
graph = "urn:graph:retrieval"
|
|
913
998
|
|
|
914
999
|
trace = {
|
|
915
1000
|
"question": None,
|
|
916
|
-
"
|
|
1001
|
+
"steps": [],
|
|
1002
|
+
"iterations": [], # Backwards compatibility for ReAct
|
|
917
1003
|
"conclusion": None,
|
|
918
1004
|
}
|
|
919
1005
|
|
|
@@ -923,64 +1009,79 @@ class ExplainabilityClient:
|
|
|
923
1009
|
return trace
|
|
924
1010
|
trace["question"] = question
|
|
925
1011
|
|
|
926
|
-
# Follow the chain
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1012
|
+
# Follow the provenance chain from the question
|
|
1013
|
+
self._follow_provenance_chain(
|
|
1014
|
+
session_uri, trace, graph, user, collection,
|
|
1015
|
+
is_first=True, max_depth=50,
|
|
1016
|
+
)
|
|
930
1017
|
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1018
|
+
# Backwards compat: populate iterations from steps
|
|
1019
|
+
trace["iterations"] = [
|
|
1020
|
+
s for s in trace["steps"] if isinstance(s, Analysis)
|
|
1021
|
+
]
|
|
1022
|
+
|
|
1023
|
+
return trace
|
|
1024
|
+
|
|
1025
|
+
def _follow_provenance_chain(
|
|
1026
|
+
self, current_uri, trace, graph, user, collection,
|
|
1027
|
+
is_first=False, max_depth=50,
|
|
1028
|
+
):
|
|
1029
|
+
"""Recursively follow the provenance chain, handling branches."""
|
|
1030
|
+
if max_depth <= 0:
|
|
1031
|
+
return
|
|
1032
|
+
|
|
1033
|
+
# Find entities derived from current_uri
|
|
1034
|
+
if is_first:
|
|
1035
|
+
derived_triples = self.flow.triples_query(
|
|
1036
|
+
p=PROV_WAS_GENERATED_BY,
|
|
1037
|
+
o=current_uri,
|
|
1038
|
+
g=graph, user=user, collection=collection,
|
|
1039
|
+
limit=20
|
|
1040
|
+
)
|
|
1041
|
+
if not derived_triples:
|
|
955
1042
|
derived_triples = self.flow.triples_query(
|
|
956
1043
|
p=PROV_WAS_DERIVED_FROM,
|
|
957
1044
|
o=current_uri,
|
|
958
|
-
g=graph,
|
|
959
|
-
|
|
960
|
-
collection=collection,
|
|
961
|
-
limit=10
|
|
1045
|
+
g=graph, user=user, collection=collection,
|
|
1046
|
+
limit=20
|
|
962
1047
|
)
|
|
1048
|
+
else:
|
|
1049
|
+
derived_triples = self.flow.triples_query(
|
|
1050
|
+
p=PROV_WAS_DERIVED_FROM,
|
|
1051
|
+
o=current_uri,
|
|
1052
|
+
g=graph, user=user, collection=collection,
|
|
1053
|
+
limit=20
|
|
1054
|
+
)
|
|
963
1055
|
|
|
964
|
-
|
|
965
|
-
|
|
1056
|
+
if not derived_triples:
|
|
1057
|
+
return
|
|
966
1058
|
|
|
967
|
-
|
|
1059
|
+
derived_uris = [
|
|
1060
|
+
extract_term_value(t.get("s", {}))
|
|
1061
|
+
for t in derived_triples
|
|
1062
|
+
]
|
|
1063
|
+
|
|
1064
|
+
for derived_uri in derived_uris:
|
|
968
1065
|
if not derived_uri:
|
|
969
|
-
|
|
1066
|
+
continue
|
|
970
1067
|
|
|
971
1068
|
entity = self.fetch_entity(derived_uri, graph, user, collection)
|
|
1069
|
+
if entity is None:
|
|
1070
|
+
continue
|
|
972
1071
|
|
|
973
|
-
if isinstance(entity, Analysis
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
elif isinstance(entity, Conclusion):
|
|
977
|
-
trace["conclusion"] = entity
|
|
978
|
-
break
|
|
979
|
-
else:
|
|
980
|
-
# Unknown entity type, stop
|
|
981
|
-
break
|
|
1072
|
+
if isinstance(entity, (Analysis, Decomposition, Finding,
|
|
1073
|
+
Plan, StepResult)):
|
|
1074
|
+
trace["steps"].append(entity)
|
|
982
1075
|
|
|
983
|
-
|
|
1076
|
+
# Continue following from this entity
|
|
1077
|
+
self._follow_provenance_chain(
|
|
1078
|
+
derived_uri, trace, graph, user, collection,
|
|
1079
|
+
max_depth=max_depth - 1,
|
|
1080
|
+
)
|
|
1081
|
+
|
|
1082
|
+
elif isinstance(entity, (Conclusion, Synthesis)):
|
|
1083
|
+
trace["steps"].append(entity)
|
|
1084
|
+
trace["conclusion"] = entity
|
|
984
1085
|
|
|
985
1086
|
def list_sessions(
|
|
986
1087
|
self,
|
|
@@ -1082,7 +1183,7 @@ class ExplainabilityClient:
|
|
|
1082
1183
|
|
|
1083
1184
|
for child_uri in all_child_uris:
|
|
1084
1185
|
entity = self.fetch_entity(child_uri, graph, user, collection)
|
|
1085
|
-
if isinstance(entity, Analysis):
|
|
1186
|
+
if isinstance(entity, (Analysis, Decomposition, Plan)):
|
|
1086
1187
|
return "agent"
|
|
1087
1188
|
if isinstance(entity, Exploration):
|
|
1088
1189
|
return "graphrag"
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
import json
|
|
3
3
|
import asyncio
|
|
4
|
-
import logging
|
|
5
4
|
|
|
6
5
|
from . request_response_spec import RequestResponse, RequestResponseSpec
|
|
7
6
|
from .. schema import PromptRequest, PromptResponse
|
|
8
7
|
|
|
9
|
-
logger = logging.getLogger(__name__)
|
|
10
|
-
|
|
11
8
|
class PromptClient(RequestResponse):
|
|
12
9
|
|
|
13
10
|
async def prompt(self, id, variables, timeout=600, streaming=False, chunk_callback=None):
|
|
14
|
-
logger.info(f"DEBUG prompt_client: prompt called, id={id}, streaming={streaming}, chunk_callback={chunk_callback is not None}")
|
|
15
11
|
|
|
16
12
|
if not streaming:
|
|
17
|
-
|
|
18
|
-
# Non-streaming path
|
|
13
|
+
|
|
19
14
|
resp = await self.request(
|
|
20
15
|
PromptRequest(
|
|
21
16
|
id = id,
|
|
@@ -36,39 +31,30 @@ class PromptClient(RequestResponse):
|
|
|
36
31
|
return json.loads(resp.object)
|
|
37
32
|
|
|
38
33
|
else:
|
|
39
|
-
|
|
40
|
-
# Streaming path - just forward chunks, don't accumulate
|
|
34
|
+
|
|
41
35
|
last_text = ""
|
|
42
36
|
last_object = None
|
|
43
37
|
|
|
44
38
|
async def forward_chunks(resp):
|
|
45
39
|
nonlocal last_text, last_object
|
|
46
|
-
logger.info(f"DEBUG prompt_client: forward_chunks called, resp.text={resp.text[:50] if resp.text else None}, end_of_stream={getattr(resp, 'end_of_stream', False)}")
|
|
47
40
|
|
|
48
41
|
if resp.error:
|
|
49
|
-
logger.error(f"DEBUG prompt_client: Error in response: {resp.error.message}")
|
|
50
42
|
raise RuntimeError(resp.error.message)
|
|
51
43
|
|
|
52
44
|
end_stream = getattr(resp, 'end_of_stream', False)
|
|
53
45
|
|
|
54
|
-
# Always call callback if there's text OR if it's the final message
|
|
55
46
|
if resp.text is not None:
|
|
56
47
|
last_text = resp.text
|
|
57
|
-
# Call chunk callback if provided with both chunk and end_of_stream flag
|
|
58
48
|
if chunk_callback:
|
|
59
|
-
logger.info(f"DEBUG prompt_client: Calling chunk_callback with end_of_stream={end_stream}")
|
|
60
49
|
if asyncio.iscoroutinefunction(chunk_callback):
|
|
61
50
|
await chunk_callback(resp.text, end_stream)
|
|
62
51
|
else:
|
|
63
52
|
chunk_callback(resp.text, end_stream)
|
|
64
53
|
elif resp.object:
|
|
65
|
-
logger.info(f"DEBUG prompt_client: Got object response")
|
|
66
54
|
last_object = resp.object
|
|
67
55
|
|
|
68
|
-
logger.info(f"DEBUG prompt_client: Returning end_of_stream={end_stream}")
|
|
69
56
|
return end_stream
|
|
70
57
|
|
|
71
|
-
logger.info("DEBUG prompt_client: Creating PromptRequest")
|
|
72
58
|
req = PromptRequest(
|
|
73
59
|
id = id,
|
|
74
60
|
terms = {
|
|
@@ -77,19 +63,16 @@ class PromptClient(RequestResponse):
|
|
|
77
63
|
},
|
|
78
64
|
streaming = True
|
|
79
65
|
)
|
|
80
|
-
|
|
66
|
+
|
|
81
67
|
await self.request(
|
|
82
68
|
req,
|
|
83
69
|
recipient=forward_chunks,
|
|
84
70
|
timeout=timeout
|
|
85
71
|
)
|
|
86
|
-
logger.info(f"DEBUG prompt_client: self.request returned, last_text={last_text[:50] if last_text else None}")
|
|
87
72
|
|
|
88
73
|
if last_text:
|
|
89
|
-
logger.info("DEBUG prompt_client: Returning last_text")
|
|
90
74
|
return last_text
|
|
91
75
|
|
|
92
|
-
logger.info("DEBUG prompt_client: Returning parsed last_object")
|
|
93
76
|
return json.loads(last_object) if last_object else None
|
|
94
77
|
|
|
95
78
|
async def extract_definitions(self, text, timeout=600):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.11"
|
|
@@ -53,6 +53,12 @@ from . uris import (
|
|
|
53
53
|
agent_thought_uri,
|
|
54
54
|
agent_observation_uri,
|
|
55
55
|
agent_final_uri,
|
|
56
|
+
# Orchestrator provenance URIs
|
|
57
|
+
agent_decomposition_uri,
|
|
58
|
+
agent_finding_uri,
|
|
59
|
+
agent_plan_uri,
|
|
60
|
+
agent_step_result_uri,
|
|
61
|
+
agent_synthesis_uri,
|
|
56
62
|
# Document RAG provenance URIs
|
|
57
63
|
docrag_question_uri,
|
|
58
64
|
docrag_grounding_uri,
|
|
@@ -94,6 +100,9 @@ from . namespaces import (
|
|
|
94
100
|
TG_GRAPH_RAG_QUESTION, TG_DOC_RAG_QUESTION, TG_AGENT_QUESTION,
|
|
95
101
|
# Agent provenance predicates
|
|
96
102
|
TG_THOUGHT, TG_ACTION, TG_ARGUMENTS, TG_OBSERVATION,
|
|
103
|
+
TG_SUBAGENT_GOAL, TG_PLAN_STEP,
|
|
104
|
+
# Orchestrator entity types
|
|
105
|
+
TG_DECOMPOSITION, TG_FINDING, TG_PLAN_TYPE, TG_STEP_RESULT,
|
|
97
106
|
# Document reference predicate
|
|
98
107
|
TG_DOCUMENT,
|
|
99
108
|
# Named graphs
|
|
@@ -124,6 +133,12 @@ from . agent import (
|
|
|
124
133
|
agent_session_triples,
|
|
125
134
|
agent_iteration_triples,
|
|
126
135
|
agent_final_triples,
|
|
136
|
+
# Orchestrator provenance triple builders
|
|
137
|
+
agent_decomposition_triples,
|
|
138
|
+
agent_finding_triples,
|
|
139
|
+
agent_plan_triples,
|
|
140
|
+
agent_step_result_triples,
|
|
141
|
+
agent_synthesis_triples,
|
|
127
142
|
)
|
|
128
143
|
|
|
129
144
|
# Vocabulary bootstrap
|
|
@@ -159,6 +174,12 @@ __all__ = [
|
|
|
159
174
|
"agent_thought_uri",
|
|
160
175
|
"agent_observation_uri",
|
|
161
176
|
"agent_final_uri",
|
|
177
|
+
# Orchestrator provenance URIs
|
|
178
|
+
"agent_decomposition_uri",
|
|
179
|
+
"agent_finding_uri",
|
|
180
|
+
"agent_plan_uri",
|
|
181
|
+
"agent_step_result_uri",
|
|
182
|
+
"agent_synthesis_uri",
|
|
162
183
|
# Document RAG provenance URIs
|
|
163
184
|
"docrag_question_uri",
|
|
164
185
|
"docrag_grounding_uri",
|
|
@@ -193,6 +214,9 @@ __all__ = [
|
|
|
193
214
|
"TG_GRAPH_RAG_QUESTION", "TG_DOC_RAG_QUESTION", "TG_AGENT_QUESTION",
|
|
194
215
|
# Agent provenance predicates
|
|
195
216
|
"TG_THOUGHT", "TG_ACTION", "TG_ARGUMENTS", "TG_OBSERVATION",
|
|
217
|
+
"TG_SUBAGENT_GOAL", "TG_PLAN_STEP",
|
|
218
|
+
# Orchestrator entity types
|
|
219
|
+
"TG_DECOMPOSITION", "TG_FINDING", "TG_PLAN_TYPE", "TG_STEP_RESULT",
|
|
196
220
|
# Document reference predicate
|
|
197
221
|
"TG_DOCUMENT",
|
|
198
222
|
# Named graphs
|
|
@@ -215,6 +239,12 @@ __all__ = [
|
|
|
215
239
|
"agent_session_triples",
|
|
216
240
|
"agent_iteration_triples",
|
|
217
241
|
"agent_final_triples",
|
|
242
|
+
# Orchestrator provenance triple builders
|
|
243
|
+
"agent_decomposition_triples",
|
|
244
|
+
"agent_finding_triples",
|
|
245
|
+
"agent_plan_triples",
|
|
246
|
+
"agent_step_result_triples",
|
|
247
|
+
"agent_synthesis_triples",
|
|
218
248
|
# Utility
|
|
219
249
|
"set_graph",
|
|
220
250
|
# Vocabulary
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Helper functions to build PROV-O triples for agent provenance.
|
|
3
3
|
|
|
4
|
-
Agent provenance tracks the reasoning trace of
|
|
4
|
+
Agent provenance tracks the reasoning trace of agent sessions:
|
|
5
5
|
- Question: The root activity with query and timestamp
|
|
6
|
-
- Analysis: Each think/act/observe cycle
|
|
7
|
-
- Conclusion: The final answer
|
|
6
|
+
- Analysis: Each think/act/observe cycle (ReAct)
|
|
7
|
+
- Conclusion: The final answer (ReAct)
|
|
8
|
+
- Decomposition: Supervisor broke question into sub-goals
|
|
9
|
+
- Finding: A subagent's result (Supervisor)
|
|
10
|
+
- Plan: Structured plan of steps (Plan-then-Execute)
|
|
11
|
+
- StepResult: A plan step's result (Plan-then-Execute)
|
|
12
|
+
- Synthesis: Final synthesised answer (Supervisor, Plan-then-Execute)
|
|
8
13
|
"""
|
|
9
14
|
|
|
10
15
|
import json
|
|
@@ -21,6 +26,8 @@ from . namespaces import (
|
|
|
21
26
|
TG_QUESTION, TG_ANALYSIS, TG_CONCLUSION, TG_DOCUMENT,
|
|
22
27
|
TG_ANSWER_TYPE, TG_REFLECTION_TYPE, TG_THOUGHT_TYPE, TG_OBSERVATION_TYPE,
|
|
23
28
|
TG_AGENT_QUESTION,
|
|
29
|
+
TG_DECOMPOSITION, TG_FINDING, TG_PLAN_TYPE, TG_STEP_RESULT,
|
|
30
|
+
TG_SYNTHESIS, TG_SUBAGENT_GOAL, TG_PLAN_STEP,
|
|
24
31
|
)
|
|
25
32
|
|
|
26
33
|
|
|
@@ -203,3 +210,97 @@ def agent_final_triples(
|
|
|
203
210
|
triples.append(_triple(final_uri, TG_DOCUMENT, _iri(document_id)))
|
|
204
211
|
|
|
205
212
|
return triples
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def agent_decomposition_triples(
|
|
216
|
+
uri: str,
|
|
217
|
+
session_uri: str,
|
|
218
|
+
goals: List[str],
|
|
219
|
+
) -> List[Triple]:
|
|
220
|
+
"""Build triples for a supervisor decomposition step."""
|
|
221
|
+
triples = [
|
|
222
|
+
_triple(uri, RDF_TYPE, _iri(PROV_ENTITY)),
|
|
223
|
+
_triple(uri, RDF_TYPE, _iri(TG_DECOMPOSITION)),
|
|
224
|
+
_triple(uri, RDFS_LABEL,
|
|
225
|
+
_literal(f"Decomposed into {len(goals)} research threads")),
|
|
226
|
+
_triple(uri, PROV_WAS_GENERATED_BY, _iri(session_uri)),
|
|
227
|
+
]
|
|
228
|
+
for goal in goals:
|
|
229
|
+
triples.append(_triple(uri, TG_SUBAGENT_GOAL, _literal(goal)))
|
|
230
|
+
return triples
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def agent_finding_triples(
|
|
234
|
+
uri: str,
|
|
235
|
+
decomposition_uri: str,
|
|
236
|
+
goal: str,
|
|
237
|
+
document_id: Optional[str] = None,
|
|
238
|
+
) -> List[Triple]:
|
|
239
|
+
"""Build triples for a subagent finding."""
|
|
240
|
+
triples = [
|
|
241
|
+
_triple(uri, RDF_TYPE, _iri(PROV_ENTITY)),
|
|
242
|
+
_triple(uri, RDF_TYPE, _iri(TG_FINDING)),
|
|
243
|
+
_triple(uri, RDF_TYPE, _iri(TG_ANSWER_TYPE)),
|
|
244
|
+
_triple(uri, RDFS_LABEL, _literal(f"Finding: {goal[:60]}")),
|
|
245
|
+
_triple(uri, PROV_WAS_DERIVED_FROM, _iri(decomposition_uri)),
|
|
246
|
+
_triple(uri, TG_SUBAGENT_GOAL, _literal(goal)),
|
|
247
|
+
]
|
|
248
|
+
if document_id:
|
|
249
|
+
triples.append(_triple(uri, TG_DOCUMENT, _iri(document_id)))
|
|
250
|
+
return triples
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
def agent_plan_triples(
|
|
254
|
+
uri: str,
|
|
255
|
+
session_uri: str,
|
|
256
|
+
steps: List[str],
|
|
257
|
+
) -> List[Triple]:
|
|
258
|
+
"""Build triples for a plan-then-execute plan."""
|
|
259
|
+
triples = [
|
|
260
|
+
_triple(uri, RDF_TYPE, _iri(PROV_ENTITY)),
|
|
261
|
+
_triple(uri, RDF_TYPE, _iri(TG_PLAN_TYPE)),
|
|
262
|
+
_triple(uri, RDFS_LABEL,
|
|
263
|
+
_literal(f"Plan with {len(steps)} steps")),
|
|
264
|
+
_triple(uri, PROV_WAS_GENERATED_BY, _iri(session_uri)),
|
|
265
|
+
]
|
|
266
|
+
for step in steps:
|
|
267
|
+
triples.append(_triple(uri, TG_PLAN_STEP, _literal(step)))
|
|
268
|
+
return triples
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def agent_step_result_triples(
|
|
272
|
+
uri: str,
|
|
273
|
+
plan_uri: str,
|
|
274
|
+
goal: str,
|
|
275
|
+
document_id: Optional[str] = None,
|
|
276
|
+
) -> List[Triple]:
|
|
277
|
+
"""Build triples for a plan step result."""
|
|
278
|
+
triples = [
|
|
279
|
+
_triple(uri, RDF_TYPE, _iri(PROV_ENTITY)),
|
|
280
|
+
_triple(uri, RDF_TYPE, _iri(TG_STEP_RESULT)),
|
|
281
|
+
_triple(uri, RDF_TYPE, _iri(TG_ANSWER_TYPE)),
|
|
282
|
+
_triple(uri, RDFS_LABEL, _literal(f"Step result: {goal[:60]}")),
|
|
283
|
+
_triple(uri, PROV_WAS_DERIVED_FROM, _iri(plan_uri)),
|
|
284
|
+
_triple(uri, TG_PLAN_STEP, _literal(goal)),
|
|
285
|
+
]
|
|
286
|
+
if document_id:
|
|
287
|
+
triples.append(_triple(uri, TG_DOCUMENT, _iri(document_id)))
|
|
288
|
+
return triples
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def agent_synthesis_triples(
|
|
292
|
+
uri: str,
|
|
293
|
+
previous_uri: str,
|
|
294
|
+
document_id: Optional[str] = None,
|
|
295
|
+
) -> List[Triple]:
|
|
296
|
+
"""Build triples for a synthesis answer."""
|
|
297
|
+
triples = [
|
|
298
|
+
_triple(uri, RDF_TYPE, _iri(PROV_ENTITY)),
|
|
299
|
+
_triple(uri, RDF_TYPE, _iri(TG_SYNTHESIS)),
|
|
300
|
+
_triple(uri, RDF_TYPE, _iri(TG_ANSWER_TYPE)),
|
|
301
|
+
_triple(uri, RDFS_LABEL, _literal("Synthesis")),
|
|
302
|
+
_triple(uri, PROV_WAS_DERIVED_FROM, _iri(previous_uri)),
|
|
303
|
+
]
|
|
304
|
+
if document_id:
|
|
305
|
+
triples.append(_triple(uri, TG_DOCUMENT, _iri(document_id)))
|
|
306
|
+
return triples
|
|
@@ -94,8 +94,14 @@ TG_SYNTHESIS = TG + "Synthesis"
|
|
|
94
94
|
TG_ANALYSIS = TG + "Analysis"
|
|
95
95
|
TG_CONCLUSION = TG + "Conclusion"
|
|
96
96
|
|
|
97
|
+
# Orchestrator entity types
|
|
98
|
+
TG_DECOMPOSITION = TG + "Decomposition" # Supervisor decomposed into sub-goals
|
|
99
|
+
TG_FINDING = TG + "Finding" # Subagent result
|
|
100
|
+
TG_PLAN_TYPE = TG + "Plan" # Plan-then-execute plan
|
|
101
|
+
TG_STEP_RESULT = TG + "StepResult" # Plan step result
|
|
102
|
+
|
|
97
103
|
# Unifying types for answer and intermediate commentary
|
|
98
|
-
TG_ANSWER_TYPE = TG + "Answer" # Final answer (Synthesis, Conclusion)
|
|
104
|
+
TG_ANSWER_TYPE = TG + "Answer" # Final answer (Synthesis, Conclusion, Finding, StepResult)
|
|
99
105
|
TG_REFLECTION_TYPE = TG + "Reflection" # Intermediate commentary (Thought, Observation)
|
|
100
106
|
TG_THOUGHT_TYPE = TG + "Thought" # Agent reasoning
|
|
101
107
|
TG_OBSERVATION_TYPE = TG + "Observation" # Agent tool result
|
|
@@ -110,6 +116,8 @@ TG_THOUGHT = TG + "thought" # Links iteration to thought sub-entity
|
|
|
110
116
|
TG_ACTION = TG + "action"
|
|
111
117
|
TG_ARGUMENTS = TG + "arguments"
|
|
112
118
|
TG_OBSERVATION = TG + "observation" # Links iteration to observation sub-entity
|
|
119
|
+
TG_SUBAGENT_GOAL = TG + "subagentGoal" # Goal string on Decomposition/Finding
|
|
120
|
+
TG_PLAN_STEP = TG + "planStep" # Step goal string on Plan/StepResult
|
|
113
121
|
|
|
114
122
|
# Named graph URIs for RDF datasets
|
|
115
123
|
# These separate different types of data while keeping them in the same collection
|
|
@@ -234,6 +234,31 @@ def agent_final_uri(session_id: str) -> str:
|
|
|
234
234
|
return f"urn:trustgraph:agent:{session_id}/final"
|
|
235
235
|
|
|
236
236
|
|
|
237
|
+
def agent_decomposition_uri(session_id: str) -> str:
|
|
238
|
+
"""Generate URI for a supervisor decomposition step."""
|
|
239
|
+
return f"urn:trustgraph:agent:{session_id}/decompose"
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def agent_finding_uri(session_id: str, index: int) -> str:
|
|
243
|
+
"""Generate URI for a subagent finding."""
|
|
244
|
+
return f"urn:trustgraph:agent:{session_id}/finding/{index}"
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def agent_plan_uri(session_id: str) -> str:
|
|
248
|
+
"""Generate URI for a plan-then-execute plan."""
|
|
249
|
+
return f"urn:trustgraph:agent:{session_id}/plan"
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def agent_step_result_uri(session_id: str, index: int) -> str:
|
|
253
|
+
"""Generate URI for a plan step result."""
|
|
254
|
+
return f"urn:trustgraph:agent:{session_id}/step/{index}"
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def agent_synthesis_uri(session_id: str) -> str:
|
|
258
|
+
"""Generate URI for a synthesis answer."""
|
|
259
|
+
return f"urn:trustgraph:agent:{session_id}/synthesis"
|
|
260
|
+
|
|
261
|
+
|
|
237
262
|
# Document RAG provenance URIs
|
|
238
263
|
# These URIs use the urn:trustgraph:docrag: namespace to distinguish
|
|
239
264
|
# document RAG provenance from graph RAG provenance
|
|
@@ -27,6 +27,8 @@ from . namespaces import (
|
|
|
27
27
|
TG_DOCUMENT_TYPE, TG_PAGE_TYPE, TG_CHUNK_TYPE, TG_SUBGRAPH_TYPE,
|
|
28
28
|
TG_CONCEPT, TG_ENTITY, TG_GROUNDING,
|
|
29
29
|
TG_ANSWER_TYPE, TG_REFLECTION_TYPE, TG_THOUGHT_TYPE, TG_OBSERVATION_TYPE,
|
|
30
|
+
TG_DECOMPOSITION, TG_FINDING, TG_PLAN_TYPE, TG_STEP_RESULT,
|
|
31
|
+
TG_SUBAGENT_GOAL, TG_PLAN_STEP,
|
|
30
32
|
)
|
|
31
33
|
|
|
32
34
|
|
|
@@ -87,6 +89,10 @@ TG_CLASS_LABELS = [
|
|
|
87
89
|
_label_triple(TG_REFLECTION_TYPE, "Reflection"),
|
|
88
90
|
_label_triple(TG_THOUGHT_TYPE, "Thought"),
|
|
89
91
|
_label_triple(TG_OBSERVATION_TYPE, "Observation"),
|
|
92
|
+
_label_triple(TG_DECOMPOSITION, "Decomposition"),
|
|
93
|
+
_label_triple(TG_FINDING, "Finding"),
|
|
94
|
+
_label_triple(TG_PLAN_TYPE, "Plan"),
|
|
95
|
+
_label_triple(TG_STEP_RESULT, "Step Result"),
|
|
90
96
|
]
|
|
91
97
|
|
|
92
98
|
# TrustGraph predicate labels
|
|
@@ -109,6 +115,8 @@ TG_PREDICATE_LABELS = [
|
|
|
109
115
|
_label_triple(TG_SOURCE_CHAR_LENGTH, "source character length"),
|
|
110
116
|
_label_triple(TG_CONCEPT, "concept"),
|
|
111
117
|
_label_triple(TG_ENTITY, "entity"),
|
|
118
|
+
_label_triple(TG_SUBAGENT_GOAL, "subagent goal"),
|
|
119
|
+
_label_triple(TG_PLAN_STEP, "plan step"),
|
|
112
120
|
]
|
|
113
121
|
|
|
114
122
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: trustgraph-base
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.11
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "2.2.10"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|