trustgraph-base 2.11.7__tar.gz → 3.0.0__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.
Potentially problematic release.
This version of trustgraph-base might be problematic. Click here for more details.
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/PKG-INFO +1 -1
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/__init__.py +11 -0
- trustgraph_base-3.0.0/trustgraph/base/action_service.py +124 -0
- trustgraph_base-3.0.0/trustgraph/base/cloze_client.py +34 -0
- trustgraph_base-3.0.0/trustgraph/base/concept_extraction_client.py +30 -0
- trustgraph_base-3.0.0/trustgraph/base/concept_extraction_service.py +121 -0
- trustgraph_base-3.0.0/trustgraph/base/decision_scoring_client.py +33 -0
- trustgraph_base-3.0.0/trustgraph/base/field_extraction_client.py +33 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/graph_rag_client.py +13 -0
- trustgraph_base-3.0.0/trustgraph/base/knowledge_retrieval_client.py +49 -0
- trustgraph_base-3.0.0/trustgraph/base/knowledge_retrieval_service.py +132 -0
- trustgraph_base-3.0.0/trustgraph/base/planner_service.py +119 -0
- trustgraph_base-3.0.0/trustgraph/base/policy_engine_service.py +120 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/prompt_client.py +10 -0
- trustgraph_base-3.0.0/trustgraph/base/verification_service.py +129 -0
- trustgraph_base-3.0.0/trustgraph/base_version.py +1 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/__init__.py +42 -0
- trustgraph_base-3.0.0/trustgraph/messaging/translators/action.py +53 -0
- trustgraph_base-3.0.0/trustgraph/messaging/translators/concept_extraction.py +42 -0
- trustgraph_base-3.0.0/trustgraph/messaging/translators/knowledge_retrieval.py +86 -0
- trustgraph_base-3.0.0/trustgraph/messaging/translators/planner.py +63 -0
- trustgraph_base-3.0.0/trustgraph/messaging/translators/policy_engine.py +68 -0
- trustgraph_base-3.0.0/trustgraph/messaging/translators/verification.py +64 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/__init__.py +6 -0
- trustgraph_base-3.0.0/trustgraph/schema/action.py +30 -0
- trustgraph_base-3.0.0/trustgraph/schema/concept_extraction.py +23 -0
- trustgraph_base-3.0.0/trustgraph/schema/knowledge_retrieval.py +53 -0
- trustgraph_base-3.0.0/trustgraph/schema/planner.py +40 -0
- trustgraph_base-3.0.0/trustgraph/schema/policy_engine.py +45 -0
- trustgraph_base-3.0.0/trustgraph/schema/verification.py +41 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph_base.egg-info/PKG-INFO +1 -1
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph_base.egg-info/SOURCES.txt +23 -0
- trustgraph_base-2.11.7/trustgraph/base_version.py +0 -1
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/README.md +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/pyproject.toml +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/setup.cfg +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/api.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/async_bulk_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/async_flow.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/async_metrics.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/async_socket_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/bulk_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/collection.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/config.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/exceptions.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/explainability.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/flow.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/knowledge.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/library.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/metrics.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/socket_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/api/types.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/agent_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/agent_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_backend.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_config_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_kafka_backend.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_librarian_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_processor.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_pulsar_backend.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_rabbitmq_backend.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/async_rr_wrapper.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/audit_publisher.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/backend.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/cassandra_config.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/chunking_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/collection_config_handler.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/config_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/consumer_spec.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/document_embeddings_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/document_embeddings_query_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/document_embeddings_store_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/dynamic_tool_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/embeddings_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/embeddings_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/flow.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/flow_processor.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/graph_embeddings_query_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/graph_embeddings_store_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/iam_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/image_to_text_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/keyword_index_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/keyword_index_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/librarian_spec.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/llm_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/logging.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/metrics.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/parameter_spec.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/policy_event_publisher.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/processor_group.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/producer_spec.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/pubsub.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/qdrant_config.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/receiver_pool.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/request_response_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/request_response_spec.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/reranker_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/reranker_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/row_embeddings_query_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/schema_compatibility.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/sender_pool.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/serialization.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/sparql_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/spec.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/structured_query_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/text_completion_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/tool_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/tool_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/tool_service_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/triples_client.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/triples_query_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/triples_store_service.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/base/workspace_processor.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/exceptions.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/ar.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/en.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/es.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/he.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/hi.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/pt.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/ru.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/sw.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/tr.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/i18n/packs/zh-cn.json +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/knowledge/document.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/log_level.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/registry.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/agent.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/base.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/cloze.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/collection.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/config.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/decision_scoring.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/diagnosis.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/document_loading.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/embeddings.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/embeddings_query.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/field_extraction.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/flow.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/iam.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/image_to_text.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/knowledge.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/library.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/metadata.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/nl_sparql.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/nlp_query.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/ontology.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/primitives.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/prompt.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/reranker.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/retrieval.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/rows_query.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/sparql_nl_query.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/sparql_query.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/structured_query.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/text_completion.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/tool.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/messaging/translators/triples.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/objects/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/objects/field.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/objects/object.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/provenance/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/provenance/agent.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/provenance/namespaces.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/provenance/triples.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/provenance/uris.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/provenance/vocabulary.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/rdf.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/agent.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/audit.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/cloze.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/config.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/core/__init__.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/core/metadata.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/core/primitives.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/core/topic.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/decision_scoring.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/documents.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/embeddings.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/field_extraction.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/iam.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/llm.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/nl_sparql.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/ontology.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/policy_event.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/retrieval.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/structured.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/triples.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph/schema/user_context.py +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph_base.egg-info/entry_points.txt +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/trustgraph_base.egg-info/requires.txt +0 -0
- {trustgraph_base-2.11.7 → trustgraph_base-3.0.0}/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:
|
|
3
|
+
Version: 3.0.0
|
|
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
|
|
@@ -55,4 +55,15 @@ from . receiver_pool import ReceiverPool, ConsumerRegistration
|
|
|
55
55
|
from . sender_pool import SenderPool, ProducerHandle
|
|
56
56
|
from . request_response_client import RequestResponseClient
|
|
57
57
|
from . async_librarian_client import AsyncLibrarianClient
|
|
58
|
+
from . concept_extraction_service import ConceptExtractionService
|
|
59
|
+
from . concept_extraction_client import ConceptExtractionClientSpec
|
|
60
|
+
from . knowledge_retrieval_service import KnowledgeRetrievalService
|
|
61
|
+
from . knowledge_retrieval_client import KnowledgeRetrievalClientSpec
|
|
62
|
+
from . planner_service import PlannerService
|
|
63
|
+
from . verification_service import VerificationService
|
|
64
|
+
from . policy_engine_service import PolicyEngineService
|
|
65
|
+
from . action_service import ActionService
|
|
66
|
+
from . cloze_client import ClozeClientSpec
|
|
67
|
+
from . decision_scoring_client import DecisionScoringClientSpec
|
|
68
|
+
from . field_extraction_client import FieldExtractionClientSpec
|
|
58
69
|
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Action worker service. Dispatches step execution to capability
|
|
3
|
+
handlers. Single service handles all capabilities via a pluggable
|
|
4
|
+
handler registry.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from argparse import ArgumentParser
|
|
10
|
+
|
|
11
|
+
import time
|
|
12
|
+
import logging
|
|
13
|
+
from prometheus_client import Histogram, Counter
|
|
14
|
+
|
|
15
|
+
from .. schema import ActionRequest, ActionResponse, Error
|
|
16
|
+
|
|
17
|
+
from . flow_processor import FlowProcessor
|
|
18
|
+
from . consumer_spec import ConsumerSpec
|
|
19
|
+
from . producer_spec import ProducerSpec
|
|
20
|
+
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
default_ident = "action"
|
|
24
|
+
default_concurrency = 10
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ActionService(FlowProcessor):
|
|
28
|
+
|
|
29
|
+
def __init__(self, **params):
|
|
30
|
+
|
|
31
|
+
id = params.get("id")
|
|
32
|
+
concurrency = params.get("concurrency", default_concurrency)
|
|
33
|
+
|
|
34
|
+
super(ActionService, self).__init__(**params | { "id": id })
|
|
35
|
+
|
|
36
|
+
self.register_specification(
|
|
37
|
+
ConsumerSpec(
|
|
38
|
+
name = "request",
|
|
39
|
+
schema = ActionRequest,
|
|
40
|
+
handler = self.on_message,
|
|
41
|
+
concurrency = concurrency,
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
self.register_specification(
|
|
46
|
+
ProducerSpec(
|
|
47
|
+
name = "response",
|
|
48
|
+
schema = ActionResponse,
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
if not hasattr(__class__, "action_duration_metric"):
|
|
53
|
+
from . metrics import BUCKETS_LLM
|
|
54
|
+
__class__.action_duration_metric = Histogram(
|
|
55
|
+
'tg_action_duration_seconds',
|
|
56
|
+
'Action worker execution latency (seconds)',
|
|
57
|
+
["processor", "capability"],
|
|
58
|
+
buckets=BUCKETS_LLM,
|
|
59
|
+
)
|
|
60
|
+
__class__.action_count_metric = Counter(
|
|
61
|
+
'tg_action_total',
|
|
62
|
+
'Action worker executions by capability',
|
|
63
|
+
["processor", "capability"],
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
async def on_message(self, msg, consumer, flow):
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
|
|
70
|
+
request = msg.value()
|
|
71
|
+
|
|
72
|
+
id = msg.properties()["id"]
|
|
73
|
+
|
|
74
|
+
logger.debug(
|
|
75
|
+
f"Handling action request {id} "
|
|
76
|
+
f"({request.capability})..."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
workspace = flow.workspace
|
|
80
|
+
|
|
81
|
+
t0 = time.monotonic()
|
|
82
|
+
response = await self.execute(workspace, request, flow)
|
|
83
|
+
__class__.action_duration_metric.labels(
|
|
84
|
+
processor=self.id,
|
|
85
|
+
capability=request.capability,
|
|
86
|
+
).observe(time.monotonic() - t0)
|
|
87
|
+
__class__.action_count_metric.labels(
|
|
88
|
+
processor=self.id,
|
|
89
|
+
capability=request.capability,
|
|
90
|
+
).inc()
|
|
91
|
+
|
|
92
|
+
logger.debug("Sending action response...")
|
|
93
|
+
await flow("response").send(response, properties={"id": id})
|
|
94
|
+
logger.debug("Action request completed")
|
|
95
|
+
|
|
96
|
+
except Exception as e:
|
|
97
|
+
|
|
98
|
+
logger.error(
|
|
99
|
+
f"Exception in action service: {e}", exc_info=True
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
logger.info("Sending error response...")
|
|
103
|
+
|
|
104
|
+
r = ActionResponse(
|
|
105
|
+
error = Error(
|
|
106
|
+
type = "action-error",
|
|
107
|
+
message = str(e),
|
|
108
|
+
),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
await flow("response").send(r, properties={"id": id})
|
|
112
|
+
|
|
113
|
+
async def execute(self, workspace, request, flow):
|
|
114
|
+
raise NotImplementedError("Subclasses must implement execute")
|
|
115
|
+
|
|
116
|
+
@staticmethod
|
|
117
|
+
def add_args(parser: ArgumentParser) -> None:
|
|
118
|
+
|
|
119
|
+
FlowProcessor.add_args(parser)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def run() -> None:
|
|
123
|
+
|
|
124
|
+
Processor.launch(default_ident, __doc__)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
from . request_response_spec import RequestResponseSpec
|
|
3
|
+
from .. schema import ClozeRequest, ClozeResponse
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ClozeClient:
|
|
7
|
+
async def predict(self, model, query, timeout=300):
|
|
8
|
+
|
|
9
|
+
resp = await self.request(
|
|
10
|
+
ClozeRequest(
|
|
11
|
+
operation="predict",
|
|
12
|
+
model=model,
|
|
13
|
+
query=query,
|
|
14
|
+
),
|
|
15
|
+
timeout=timeout,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
if resp.error:
|
|
19
|
+
raise RuntimeError(resp.error.message)
|
|
20
|
+
|
|
21
|
+
return resp
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ClozeClientSpec(RequestResponseSpec):
|
|
25
|
+
def __init__(
|
|
26
|
+
self, request_name, response_name,
|
|
27
|
+
):
|
|
28
|
+
super(ClozeClientSpec, self).__init__(
|
|
29
|
+
request_name=request_name,
|
|
30
|
+
request_schema=ClozeRequest,
|
|
31
|
+
response_name=response_name,
|
|
32
|
+
response_schema=ClozeResponse,
|
|
33
|
+
impl=ClozeClient,
|
|
34
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
from . request_response_spec import RequestResponseSpec
|
|
3
|
+
from .. schema import ConceptExtractionRequest, ConceptExtractionResponse
|
|
4
|
+
|
|
5
|
+
class ConceptExtractionClient:
|
|
6
|
+
async def extract(self, query, timeout=300):
|
|
7
|
+
|
|
8
|
+
resp = await self.request(
|
|
9
|
+
ConceptExtractionRequest(
|
|
10
|
+
query=query,
|
|
11
|
+
),
|
|
12
|
+
timeout=timeout,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
if resp.error:
|
|
16
|
+
raise RuntimeError(resp.error.message)
|
|
17
|
+
|
|
18
|
+
return resp.concepts
|
|
19
|
+
|
|
20
|
+
class ConceptExtractionClientSpec(RequestResponseSpec):
|
|
21
|
+
def __init__(
|
|
22
|
+
self, request_name, response_name,
|
|
23
|
+
):
|
|
24
|
+
super(ConceptExtractionClientSpec, self).__init__(
|
|
25
|
+
request_name = request_name,
|
|
26
|
+
request_schema = ConceptExtractionRequest,
|
|
27
|
+
response_name = response_name,
|
|
28
|
+
response_schema = ConceptExtractionResponse,
|
|
29
|
+
impl = ConceptExtractionClient,
|
|
30
|
+
)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Concept extraction service. Input is a natural-language query.
|
|
3
|
+
Output is a list of key concepts extracted from the query.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from argparse import ArgumentParser
|
|
9
|
+
|
|
10
|
+
import time
|
|
11
|
+
import logging
|
|
12
|
+
from prometheus_client import Histogram, Counter
|
|
13
|
+
|
|
14
|
+
from .. schema import (
|
|
15
|
+
ConceptExtractionRequest, ConceptExtractionResponse, Error,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
from . flow_processor import FlowProcessor
|
|
19
|
+
from . consumer_spec import ConsumerSpec
|
|
20
|
+
from . producer_spec import ProducerSpec
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
default_ident = "concept-extraction"
|
|
25
|
+
default_concurrency = 10
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ConceptExtractionService(FlowProcessor):
|
|
29
|
+
|
|
30
|
+
def __init__(self, **params):
|
|
31
|
+
|
|
32
|
+
id = params.get("id")
|
|
33
|
+
concurrency = params.get("concurrency", default_concurrency)
|
|
34
|
+
|
|
35
|
+
super(ConceptExtractionService, self).__init__(**params | { "id": id })
|
|
36
|
+
|
|
37
|
+
self.register_specification(
|
|
38
|
+
ConsumerSpec(
|
|
39
|
+
name = "request",
|
|
40
|
+
schema = ConceptExtractionRequest,
|
|
41
|
+
handler = self.on_message,
|
|
42
|
+
concurrency = concurrency,
|
|
43
|
+
)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
self.register_specification(
|
|
47
|
+
ProducerSpec(
|
|
48
|
+
name = "response",
|
|
49
|
+
schema = ConceptExtractionResponse,
|
|
50
|
+
)
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
if not hasattr(__class__, "extract_duration_metric"):
|
|
54
|
+
from . metrics import BUCKETS_LLM
|
|
55
|
+
__class__.extract_duration_metric = Histogram(
|
|
56
|
+
'tg_concept_extraction_duration_seconds',
|
|
57
|
+
'Concept extraction latency (seconds)',
|
|
58
|
+
["processor"],
|
|
59
|
+
buckets=BUCKETS_LLM,
|
|
60
|
+
)
|
|
61
|
+
__class__.extract_count_metric = Counter(
|
|
62
|
+
'tg_concept_extraction_total',
|
|
63
|
+
'Number of concept extraction requests',
|
|
64
|
+
["processor"],
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
async def on_message(self, msg, consumer, flow):
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
|
|
71
|
+
request = msg.value()
|
|
72
|
+
|
|
73
|
+
id = msg.properties()["id"]
|
|
74
|
+
|
|
75
|
+
logger.debug(f"Handling concept extraction request {id}...")
|
|
76
|
+
|
|
77
|
+
workspace = flow.workspace
|
|
78
|
+
|
|
79
|
+
t0 = time.monotonic()
|
|
80
|
+
response = await self.extract(workspace, request, flow)
|
|
81
|
+
__class__.extract_duration_metric.labels(
|
|
82
|
+
processor=self.id,
|
|
83
|
+
).observe(time.monotonic() - t0)
|
|
84
|
+
__class__.extract_count_metric.labels(
|
|
85
|
+
processor=self.id,
|
|
86
|
+
).inc()
|
|
87
|
+
|
|
88
|
+
logger.debug("Sending concept extraction response...")
|
|
89
|
+
await flow("response").send(response, properties={"id": id})
|
|
90
|
+
logger.debug("Concept extraction request completed")
|
|
91
|
+
|
|
92
|
+
except Exception as e:
|
|
93
|
+
|
|
94
|
+
logger.error(
|
|
95
|
+
f"Exception in concept extraction service: {e}",
|
|
96
|
+
exc_info=True,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
logger.info("Sending error response...")
|
|
100
|
+
|
|
101
|
+
r = ConceptExtractionResponse(
|
|
102
|
+
error = Error(
|
|
103
|
+
type = "concept-extraction-error",
|
|
104
|
+
message = str(e),
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
await flow("response").send(r, properties={"id": id})
|
|
109
|
+
|
|
110
|
+
async def extract(self, workspace, request, flow):
|
|
111
|
+
raise NotImplementedError("Subclasses must implement extract")
|
|
112
|
+
|
|
113
|
+
@staticmethod
|
|
114
|
+
def add_args(parser: ArgumentParser) -> None:
|
|
115
|
+
|
|
116
|
+
FlowProcessor.add_args(parser)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def run() -> None:
|
|
120
|
+
|
|
121
|
+
Processor.launch(default_ident, __doc__)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
from . request_response_spec import RequestResponseSpec
|
|
3
|
+
from .. schema import DecisionScoringRequest, DecisionScoringResponse
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DecisionScoringClient:
|
|
7
|
+
async def score(self, state, questions, timeout=300):
|
|
8
|
+
|
|
9
|
+
resp = await self.request(
|
|
10
|
+
DecisionScoringRequest(
|
|
11
|
+
state=state,
|
|
12
|
+
questions=questions,
|
|
13
|
+
),
|
|
14
|
+
timeout=timeout,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
if resp.error:
|
|
18
|
+
raise RuntimeError(resp.error.message)
|
|
19
|
+
|
|
20
|
+
return resp
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class DecisionScoringClientSpec(RequestResponseSpec):
|
|
24
|
+
def __init__(
|
|
25
|
+
self, request_name, response_name,
|
|
26
|
+
):
|
|
27
|
+
super(DecisionScoringClientSpec, self).__init__(
|
|
28
|
+
request_name=request_name,
|
|
29
|
+
request_schema=DecisionScoringRequest,
|
|
30
|
+
response_name=response_name,
|
|
31
|
+
response_schema=DecisionScoringResponse,
|
|
32
|
+
impl=DecisionScoringClient,
|
|
33
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
from . request_response_spec import RequestResponseSpec
|
|
3
|
+
from .. schema import FieldExtractionRequest, FieldExtractionResponse
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FieldExtractionClient:
|
|
7
|
+
async def extract(self, state, fields, timeout=300):
|
|
8
|
+
|
|
9
|
+
resp = await self.request(
|
|
10
|
+
FieldExtractionRequest(
|
|
11
|
+
state=state,
|
|
12
|
+
fields=fields,
|
|
13
|
+
),
|
|
14
|
+
timeout=timeout,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
if resp.error:
|
|
18
|
+
raise RuntimeError(resp.error.message)
|
|
19
|
+
|
|
20
|
+
return resp
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class FieldExtractionClientSpec(RequestResponseSpec):
|
|
24
|
+
def __init__(
|
|
25
|
+
self, request_name, response_name,
|
|
26
|
+
):
|
|
27
|
+
super(FieldExtractionClientSpec, self).__init__(
|
|
28
|
+
request_name=request_name,
|
|
29
|
+
request_schema=FieldExtractionRequest,
|
|
30
|
+
response_name=response_name,
|
|
31
|
+
response_schema=FieldExtractionResponse,
|
|
32
|
+
impl=FieldExtractionClient,
|
|
33
|
+
)
|
|
@@ -4,12 +4,17 @@ from .. schema import GraphRagQuery, GraphRagResponse
|
|
|
4
4
|
|
|
5
5
|
class GraphRagClient:
|
|
6
6
|
async def rag(self, query, collection="default",
|
|
7
|
+
entity_limit=0, triple_limit=0,
|
|
8
|
+
max_subgraph_size=0, max_path_length=0,
|
|
9
|
+
edge_score_limit=0, edge_limit=0,
|
|
10
|
+
max_reranker_input=0,
|
|
7
11
|
chunk_callback=None, explain_callback=None,
|
|
8
12
|
parent_uri="",
|
|
9
13
|
grounding_seeds=None,
|
|
10
14
|
graph_seeds=None,
|
|
11
15
|
languages=None,
|
|
12
16
|
traversal_instructions=None,
|
|
17
|
+
graph=None,
|
|
13
18
|
timeout=600):
|
|
14
19
|
"""
|
|
15
20
|
Execute a graph RAG query with optional streaming callbacks.
|
|
@@ -53,11 +58,19 @@ class GraphRagClient:
|
|
|
53
58
|
GraphRagQuery(
|
|
54
59
|
query = query,
|
|
55
60
|
collection = collection,
|
|
61
|
+
entity_limit = entity_limit,
|
|
62
|
+
triple_limit = triple_limit,
|
|
63
|
+
max_subgraph_size = max_subgraph_size,
|
|
64
|
+
max_path_length = max_path_length,
|
|
65
|
+
edge_score_limit = edge_score_limit,
|
|
66
|
+
edge_limit = edge_limit,
|
|
67
|
+
max_reranker_input = max_reranker_input,
|
|
56
68
|
parent_uri = parent_uri,
|
|
57
69
|
grounding_seeds = grounding_seeds or [],
|
|
58
70
|
graph_seeds = graph_seeds or [],
|
|
59
71
|
languages = languages or [],
|
|
60
72
|
traversal_instructions = traversal_instructions or [],
|
|
73
|
+
graph = graph,
|
|
61
74
|
),
|
|
62
75
|
timeout=timeout,
|
|
63
76
|
recipient=recipient,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
from . request_response_spec import RequestResponseSpec
|
|
3
|
+
from .. schema import (
|
|
4
|
+
KnowledgeRetrievalRequest, KnowledgeRetrievalResponse,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
class KnowledgeRetrievalClient:
|
|
8
|
+
async def retrieve(
|
|
9
|
+
self, concepts=None, entities=None,
|
|
10
|
+
collection="default",
|
|
11
|
+
entity_limit=50, triple_limit=30,
|
|
12
|
+
max_path_length=2, edge_limit=25,
|
|
13
|
+
max_reranker_input=350,
|
|
14
|
+
languages=None, graph="",
|
|
15
|
+
timeout=300,
|
|
16
|
+
):
|
|
17
|
+
|
|
18
|
+
resp = await self.request(
|
|
19
|
+
KnowledgeRetrievalRequest(
|
|
20
|
+
concepts=concepts or [],
|
|
21
|
+
entities=entities or [],
|
|
22
|
+
collection=collection,
|
|
23
|
+
entity_limit=entity_limit,
|
|
24
|
+
triple_limit=triple_limit,
|
|
25
|
+
max_path_length=max_path_length,
|
|
26
|
+
edge_limit=edge_limit,
|
|
27
|
+
max_reranker_input=max_reranker_input,
|
|
28
|
+
languages=languages or [],
|
|
29
|
+
graph=graph,
|
|
30
|
+
),
|
|
31
|
+
timeout=timeout,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if resp.error:
|
|
35
|
+
raise RuntimeError(resp.error.message)
|
|
36
|
+
|
|
37
|
+
return resp
|
|
38
|
+
|
|
39
|
+
class KnowledgeRetrievalClientSpec(RequestResponseSpec):
|
|
40
|
+
def __init__(
|
|
41
|
+
self, request_name, response_name,
|
|
42
|
+
):
|
|
43
|
+
super(KnowledgeRetrievalClientSpec, self).__init__(
|
|
44
|
+
request_name = request_name,
|
|
45
|
+
request_schema = KnowledgeRetrievalRequest,
|
|
46
|
+
response_name = response_name,
|
|
47
|
+
response_schema = KnowledgeRetrievalResponse,
|
|
48
|
+
impl = KnowledgeRetrievalClient,
|
|
49
|
+
)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Knowledge retrieval service. Input is concepts, seed entities, or
|
|
3
|
+
graph node URIs. Output is a ranked subgraph of edges retrieved
|
|
4
|
+
via embedding lookup, graph traversal, and cross-encoder reranking.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from argparse import ArgumentParser
|
|
10
|
+
|
|
11
|
+
import time
|
|
12
|
+
import logging
|
|
13
|
+
from prometheus_client import Histogram, Counter
|
|
14
|
+
|
|
15
|
+
from .. schema import (
|
|
16
|
+
KnowledgeRetrievalRequest, KnowledgeRetrievalResponse, Error,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from . flow_processor import FlowProcessor
|
|
20
|
+
from . consumer_spec import ConsumerSpec
|
|
21
|
+
from . producer_spec import ProducerSpec
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger(__name__)
|
|
24
|
+
|
|
25
|
+
default_ident = "knowledge-retrieval"
|
|
26
|
+
default_concurrency = 1
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class KnowledgeRetrievalService(FlowProcessor):
|
|
30
|
+
|
|
31
|
+
def __init__(self, **params):
|
|
32
|
+
|
|
33
|
+
id = params.get("id")
|
|
34
|
+
concurrency = params.get("concurrency", default_concurrency)
|
|
35
|
+
|
|
36
|
+
super(KnowledgeRetrievalService, self).__init__(
|
|
37
|
+
**params | { "id": id }
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
self.register_specification(
|
|
41
|
+
ConsumerSpec(
|
|
42
|
+
name = "request",
|
|
43
|
+
schema = KnowledgeRetrievalRequest,
|
|
44
|
+
handler = self.on_message,
|
|
45
|
+
concurrency = concurrency,
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
self.register_specification(
|
|
50
|
+
ProducerSpec(
|
|
51
|
+
name = "response",
|
|
52
|
+
schema = KnowledgeRetrievalResponse,
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if not hasattr(__class__, "retrieval_duration_metric"):
|
|
57
|
+
from . metrics import BUCKETS_LLM
|
|
58
|
+
__class__.retrieval_duration_metric = Histogram(
|
|
59
|
+
'tg_knowledge_retrieval_duration_seconds',
|
|
60
|
+
'Knowledge retrieval latency (seconds)',
|
|
61
|
+
["processor"],
|
|
62
|
+
buckets=BUCKETS_LLM,
|
|
63
|
+
)
|
|
64
|
+
__class__.retrieval_count_metric = Counter(
|
|
65
|
+
'tg_knowledge_retrieval_total',
|
|
66
|
+
'Number of knowledge retrieval requests',
|
|
67
|
+
["processor"],
|
|
68
|
+
)
|
|
69
|
+
__class__.retrieval_edges_metric = Counter(
|
|
70
|
+
'tg_knowledge_retrieval_edges_total',
|
|
71
|
+
'Total edges returned by knowledge retrieval',
|
|
72
|
+
["processor"],
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
async def on_message(self, msg, consumer, flow):
|
|
76
|
+
|
|
77
|
+
try:
|
|
78
|
+
|
|
79
|
+
request = msg.value()
|
|
80
|
+
|
|
81
|
+
id = msg.properties()["id"]
|
|
82
|
+
|
|
83
|
+
logger.debug(f"Handling knowledge retrieval request {id}...")
|
|
84
|
+
|
|
85
|
+
workspace = flow.workspace
|
|
86
|
+
|
|
87
|
+
t0 = time.monotonic()
|
|
88
|
+
response = await self.retrieve(workspace, request, flow)
|
|
89
|
+
__class__.retrieval_duration_metric.labels(
|
|
90
|
+
processor=self.id,
|
|
91
|
+
).observe(time.monotonic() - t0)
|
|
92
|
+
__class__.retrieval_count_metric.labels(
|
|
93
|
+
processor=self.id,
|
|
94
|
+
).inc()
|
|
95
|
+
__class__.retrieval_edges_metric.labels(
|
|
96
|
+
processor=self.id,
|
|
97
|
+
).inc(len(response.edges))
|
|
98
|
+
|
|
99
|
+
logger.debug("Sending knowledge retrieval response...")
|
|
100
|
+
await flow("response").send(response, properties={"id": id})
|
|
101
|
+
logger.debug("Knowledge retrieval request completed")
|
|
102
|
+
|
|
103
|
+
except Exception as e:
|
|
104
|
+
|
|
105
|
+
logger.error(
|
|
106
|
+
f"Exception in knowledge retrieval service: {e}",
|
|
107
|
+
exc_info=True,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
logger.info("Sending error response...")
|
|
111
|
+
|
|
112
|
+
r = KnowledgeRetrievalResponse(
|
|
113
|
+
error = Error(
|
|
114
|
+
type = "knowledge-retrieval-error",
|
|
115
|
+
message = str(e),
|
|
116
|
+
),
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
await flow("response").send(r, properties={"id": id})
|
|
120
|
+
|
|
121
|
+
async def retrieve(self, workspace, request, flow):
|
|
122
|
+
raise NotImplementedError("Subclasses must implement retrieve")
|
|
123
|
+
|
|
124
|
+
@staticmethod
|
|
125
|
+
def add_args(parser: ArgumentParser) -> None:
|
|
126
|
+
|
|
127
|
+
FlowProcessor.add_args(parser)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def run() -> None:
|
|
131
|
+
|
|
132
|
+
Processor.launch(default_ident, __doc__)
|