trustgraph-base 2.2.14__tar.gz → 2.2.15__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.14 → trustgraph_base-2.2.15}/PKG-INFO +1 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/__init__.py +1 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/async_processor.py +4 -13
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/flow_processor.py +0 -2
- trustgraph_base-2.2.15/trustgraph/base/pubsub.py +72 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/pulsar_backend.py +28 -19
- trustgraph_base-2.2.15/trustgraph/base_version.py +1 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/agent_client.py +1 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/base.py +2 -12
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/config_client.py +1 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/document_embeddings_client.py +1 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/document_rag_client.py +0 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/embeddings_client.py +1 -8
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/graph_embeddings_client.py +1 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/graph_rag_client.py +0 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/llm_client.py +1 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/prompt_client.py +1 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/row_embeddings_client.py +1 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/triples_query_client.py +1 -7
- trustgraph_base-2.2.15/trustgraph/log_level.py +12 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/agent.py +6 -6
- trustgraph_base-2.2.15/trustgraph/messaging/translators/base.py +46 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/collection.py +4 -4
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/config.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/diagnosis.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/document_loading.py +8 -8
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/embeddings.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/embeddings_query.py +19 -19
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/flow.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/knowledge.py +12 -12
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/library.py +13 -13
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/metadata.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/nlp_query.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/primitives.py +28 -28
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/prompt.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/retrieval.py +12 -12
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/rows_query.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/structured_query.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/text_completion.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/tool.py +6 -6
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/triples.py +13 -13
- trustgraph_base-2.2.15/trustgraph/schema/core/topic.py +26 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/document.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/embeddings.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/graph.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/knowledge.py +3 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/nlp.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/object.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/rows.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/structured.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/agent.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/collection.py +3 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/config.py +4 -10
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/flow.py +3 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/library.py +3 -7
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/llm.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/lookup.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/nlp_query.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/prompt.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/query.py +5 -13
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/retrieval.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/rows_query.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/structured_query.py +0 -1
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/PKG-INFO +1 -1
- trustgraph_base-2.2.14/trustgraph/base/pubsub.py +0 -110
- trustgraph_base-2.2.14/trustgraph/base_version.py +0 -1
- trustgraph_base-2.2.14/trustgraph/log_level.py +0 -20
- trustgraph_base-2.2.14/trustgraph/messaging/translators/base.py +0 -43
- trustgraph_base-2.2.14/trustgraph/schema/core/topic.py +0 -23
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/README.md +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/pyproject.toml +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/setup.cfg +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/api.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_bulk_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_flow.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_metrics.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_socket_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/bulk_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/collection.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/config.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/exceptions.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/explainability.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/flow.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/knowledge.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/library.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/metrics.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/socket_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/types.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/agent_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/agent_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/backend.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/cassandra_config.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/chunking_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/collection_config_handler.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/consumer.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/consumer_spec.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/document_embeddings_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/document_embeddings_query_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/document_embeddings_store_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/dynamic_tool_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/embeddings_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/embeddings_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/flow.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_embeddings_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_embeddings_query_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_embeddings_store_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_rag_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/llm_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/logging.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/metrics.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/parameter_spec.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/producer.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/producer_spec.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/prompt_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/publisher.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/request_response_spec.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/row_embeddings_query_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/spec.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/structured_query_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/subscriber.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/subscriber_spec.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/text_completion_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/tool_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/tool_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/tool_service_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/triples_client.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/triples_query_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/triples_store_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/exceptions.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/defs.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/document.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/identifier.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/organization.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/publication.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/registry.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/objects/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/objects/field.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/objects/object.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/agent.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/namespaces.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/triples.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/uris.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/vocabulary.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/rdf.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/core/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/core/metadata.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/core/primitives.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/__init__.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/diagnosis.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/storage.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/tool_service.py +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/SOURCES.txt +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/dependency_links.txt +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/requires.txt +0 -0
- {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/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.15
|
|
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
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
import asyncio
|
|
8
8
|
import argparse
|
|
9
|
-
import _pulsar
|
|
10
9
|
import time
|
|
11
10
|
import uuid
|
|
12
11
|
import logging
|
|
@@ -15,7 +14,7 @@ from prometheus_client import start_http_server, Info
|
|
|
15
14
|
|
|
16
15
|
from .. schema import ConfigPush, config_push_queue
|
|
17
16
|
from .. log_level import LogLevel
|
|
18
|
-
from . pubsub import
|
|
17
|
+
from . pubsub import get_pubsub, add_pubsub_args
|
|
19
18
|
from . producer import Producer
|
|
20
19
|
from . consumer import Consumer
|
|
21
20
|
from . metrics import ProcessorMetrics, ConsumerMetrics
|
|
@@ -223,8 +222,8 @@ class AsyncProcessor:
|
|
|
223
222
|
logger.info("Keyboard interrupt.")
|
|
224
223
|
return
|
|
225
224
|
|
|
226
|
-
except
|
|
227
|
-
logger.info("
|
|
225
|
+
except KeyboardInterrupt:
|
|
226
|
+
logger.info("Interrupted.")
|
|
228
227
|
return
|
|
229
228
|
|
|
230
229
|
# Exceptions from a taskgroup come in as an exception group
|
|
@@ -250,15 +249,7 @@ class AsyncProcessor:
|
|
|
250
249
|
@staticmethod
|
|
251
250
|
def add_args(parser):
|
|
252
251
|
|
|
253
|
-
|
|
254
|
-
parser.add_argument(
|
|
255
|
-
'--pubsub-backend',
|
|
256
|
-
default=os.getenv('PUBSUB_BACKEND', 'pulsar'),
|
|
257
|
-
choices=['pulsar', 'mqtt'],
|
|
258
|
-
help='Pub/sub backend (default: pulsar, env: PUBSUB_BACKEND)',
|
|
259
|
-
)
|
|
260
|
-
|
|
261
|
-
PulsarClient.add_args(parser)
|
|
252
|
+
add_pubsub_args(parser)
|
|
262
253
|
add_logging_args(parser)
|
|
263
254
|
|
|
264
255
|
parser.add_argument(
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
import os
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
logger = logging.getLogger(__name__)
|
|
6
|
+
|
|
7
|
+
# Default connection settings from environment
|
|
8
|
+
DEFAULT_PULSAR_HOST = os.getenv("PULSAR_HOST", 'pulsar://pulsar:6650')
|
|
9
|
+
DEFAULT_PULSAR_API_KEY = os.getenv("PULSAR_API_KEY", None)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_pubsub(**config):
|
|
13
|
+
"""
|
|
14
|
+
Factory function to create a pub/sub backend based on configuration.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
config: Configuration dictionary from command-line args.
|
|
18
|
+
Key 'pubsub_backend' selects the backend (default: 'pulsar').
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
Backend instance implementing the PubSubBackend protocol.
|
|
22
|
+
"""
|
|
23
|
+
backend_type = config.get('pubsub_backend', 'pulsar')
|
|
24
|
+
|
|
25
|
+
if backend_type == 'pulsar':
|
|
26
|
+
from .pulsar_backend import PulsarBackend
|
|
27
|
+
return PulsarBackend(
|
|
28
|
+
host=config.get('pulsar_host', DEFAULT_PULSAR_HOST),
|
|
29
|
+
api_key=config.get('pulsar_api_key', DEFAULT_PULSAR_API_KEY),
|
|
30
|
+
listener=config.get('pulsar_listener'),
|
|
31
|
+
)
|
|
32
|
+
else:
|
|
33
|
+
raise ValueError(f"Unknown pub/sub backend: {backend_type}")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
STANDALONE_PULSAR_HOST = 'pulsar://localhost:6650'
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def add_pubsub_args(parser, standalone=False):
|
|
40
|
+
"""Add pub/sub CLI arguments to an argument parser.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
parser: argparse.ArgumentParser
|
|
44
|
+
standalone: If True, default host is localhost (for CLI tools
|
|
45
|
+
that run outside containers)
|
|
46
|
+
"""
|
|
47
|
+
host = STANDALONE_PULSAR_HOST if standalone else DEFAULT_PULSAR_HOST
|
|
48
|
+
listener_default = 'localhost' if standalone else None
|
|
49
|
+
|
|
50
|
+
parser.add_argument(
|
|
51
|
+
'--pubsub-backend',
|
|
52
|
+
default=os.getenv('PUBSUB_BACKEND', 'pulsar'),
|
|
53
|
+
help='Pub/sub backend (default: pulsar, env: PUBSUB_BACKEND)',
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
parser.add_argument(
|
|
57
|
+
'-p', '--pulsar-host',
|
|
58
|
+
default=host,
|
|
59
|
+
help=f'Pulsar host (default: {host})',
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
'--pulsar-api-key',
|
|
64
|
+
default=DEFAULT_PULSAR_API_KEY,
|
|
65
|
+
help='Pulsar API key',
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
parser.add_argument(
|
|
69
|
+
'--pulsar-listener',
|
|
70
|
+
default=listener_default,
|
|
71
|
+
help=f'Pulsar listener (default: {listener_default or "none"})',
|
|
72
|
+
)
|
|
@@ -181,8 +181,11 @@ class PulsarBackendConsumer:
|
|
|
181
181
|
self._schema_cls = schema_cls
|
|
182
182
|
|
|
183
183
|
def receive(self, timeout_millis: int = 2000) -> Message:
|
|
184
|
-
"""Receive a message."""
|
|
185
|
-
|
|
184
|
+
"""Receive a message. Raises TimeoutError if no message available."""
|
|
185
|
+
try:
|
|
186
|
+
pulsar_msg = self._consumer.receive(timeout_millis=timeout_millis)
|
|
187
|
+
except _pulsar.Timeout:
|
|
188
|
+
raise TimeoutError("No message received within timeout")
|
|
186
189
|
return PulsarMessage(pulsar_msg, self._schema_cls)
|
|
187
190
|
|
|
188
191
|
def acknowledge(self, message: Message) -> None:
|
|
@@ -237,38 +240,44 @@ class PulsarBackend:
|
|
|
237
240
|
self.client = pulsar.Client(**client_args)
|
|
238
241
|
logger.info(f"Pulsar client connected to {host}")
|
|
239
242
|
|
|
240
|
-
def map_topic(self,
|
|
243
|
+
def map_topic(self, queue_id: str) -> str:
|
|
241
244
|
"""
|
|
242
|
-
Map
|
|
245
|
+
Map queue identifier to Pulsar URI.
|
|
243
246
|
|
|
244
|
-
Format:
|
|
245
|
-
Example:
|
|
247
|
+
Format: class:topicspace:topic
|
|
248
|
+
Example: flow:tg:text-completion-request -> persistent://tg/flow/text-completion-request
|
|
246
249
|
|
|
247
250
|
Args:
|
|
248
|
-
|
|
251
|
+
queue_id: Queue identifier string or already-formatted Pulsar URI
|
|
249
252
|
|
|
250
253
|
Returns:
|
|
251
254
|
Pulsar topic URI
|
|
252
255
|
"""
|
|
253
256
|
# If already a Pulsar URI, return as-is
|
|
254
|
-
if '://' in
|
|
255
|
-
return
|
|
257
|
+
if '://' in queue_id:
|
|
258
|
+
return queue_id
|
|
256
259
|
|
|
257
|
-
parts =
|
|
258
|
-
if len(parts) !=
|
|
259
|
-
raise ValueError(
|
|
260
|
+
parts = queue_id.split(':', 2)
|
|
261
|
+
if len(parts) != 3:
|
|
262
|
+
raise ValueError(
|
|
263
|
+
f"Invalid queue format: {queue_id}, "
|
|
264
|
+
f"expected class:topicspace:topic"
|
|
265
|
+
)
|
|
260
266
|
|
|
261
|
-
|
|
267
|
+
cls, topicspace, topic = parts
|
|
262
268
|
|
|
263
|
-
# Map
|
|
264
|
-
if
|
|
265
|
-
persistence = 'non-persistent'
|
|
266
|
-
elif qos in ['q1', 'q2']:
|
|
269
|
+
# Map class to Pulsar persistence and namespace
|
|
270
|
+
if cls in ('flow', 'state'):
|
|
267
271
|
persistence = 'persistent'
|
|
272
|
+
elif cls in ('request', 'response'):
|
|
273
|
+
persistence = 'non-persistent'
|
|
268
274
|
else:
|
|
269
|
-
raise ValueError(
|
|
275
|
+
raise ValueError(
|
|
276
|
+
f"Invalid queue class: {cls}, "
|
|
277
|
+
f"expected flow, request, response, or state"
|
|
278
|
+
)
|
|
270
279
|
|
|
271
|
-
return f"{persistence}://{
|
|
280
|
+
return f"{persistence}://{topicspace}/{cls}/{topic}"
|
|
272
281
|
|
|
273
282
|
def create_producer(self, topic: str, schema: type, **options) -> BackendProducer:
|
|
274
283
|
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.2.15"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
|
|
4
3
|
from .. schema import AgentRequest, AgentResponse
|
|
5
4
|
from .. schema import agent_request_queue
|
|
@@ -7,15 +6,11 @@ from .. schema import agent_response_queue
|
|
|
7
6
|
from . base import BaseClient
|
|
8
7
|
|
|
9
8
|
# Ugly
|
|
10
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
11
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
12
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
13
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
14
9
|
|
|
15
10
|
class AgentClient(BaseClient):
|
|
16
11
|
|
|
17
12
|
def __init__(
|
|
18
|
-
self,
|
|
13
|
+
self,
|
|
19
14
|
subscriber=None,
|
|
20
15
|
input_queue=None,
|
|
21
16
|
output_queue=None,
|
|
@@ -27,7 +22,6 @@ class AgentClient(BaseClient):
|
|
|
27
22
|
if output_queue is None: output_queue = agent_response_queue
|
|
28
23
|
|
|
29
24
|
super(AgentClient, self).__init__(
|
|
30
|
-
log_level=log_level,
|
|
31
25
|
subscriber=subscriber,
|
|
32
26
|
input_queue=input_queue,
|
|
33
27
|
output_queue=output_queue,
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import pulsar
|
|
3
|
-
import _pulsar
|
|
4
|
-
import hashlib
|
|
5
2
|
import uuid
|
|
6
3
|
import time
|
|
7
|
-
from pulsar.schema import JsonSchema
|
|
8
4
|
|
|
9
5
|
from .. exceptions import *
|
|
10
6
|
from ..base.pubsub import get_pubsub
|
|
@@ -12,16 +8,11 @@ from ..base.pubsub import get_pubsub
|
|
|
12
8
|
# Default timeout for a request/response. In seconds.
|
|
13
9
|
DEFAULT_TIMEOUT=300
|
|
14
10
|
|
|
15
|
-
# Ugly
|
|
16
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
17
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
18
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
19
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
20
11
|
|
|
21
12
|
class BaseClient:
|
|
22
13
|
|
|
23
14
|
def __init__(
|
|
24
|
-
self,
|
|
15
|
+
self,
|
|
25
16
|
subscriber=None,
|
|
26
17
|
input_queue=None,
|
|
27
18
|
output_queue=None,
|
|
@@ -87,7 +78,7 @@ class BaseClient:
|
|
|
87
78
|
|
|
88
79
|
try:
|
|
89
80
|
msg = self.consumer.receive(timeout_millis=2500)
|
|
90
|
-
except
|
|
81
|
+
except TimeoutError:
|
|
91
82
|
continue
|
|
92
83
|
|
|
93
84
|
mid = msg.properties()["id"]
|
|
@@ -139,4 +130,3 @@ class BaseClient:
|
|
|
139
130
|
|
|
140
131
|
if hasattr(self, "backend"):
|
|
141
132
|
self.backend.close()
|
|
142
|
-
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
import json
|
|
4
3
|
import dataclasses
|
|
5
4
|
|
|
@@ -9,10 +8,6 @@ from .. schema import config_response_queue
|
|
|
9
8
|
from . base import BaseClient
|
|
10
9
|
|
|
11
10
|
# Ugly
|
|
12
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
13
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
14
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
15
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
16
11
|
|
|
17
12
|
@dataclasses.dataclass
|
|
18
13
|
class Definition:
|
|
@@ -34,7 +29,7 @@ class Topic:
|
|
|
34
29
|
class ConfigClient(BaseClient):
|
|
35
30
|
|
|
36
31
|
def __init__(
|
|
37
|
-
self,
|
|
32
|
+
self,
|
|
38
33
|
subscriber=None,
|
|
39
34
|
input_queue=None,
|
|
40
35
|
output_queue=None,
|
|
@@ -50,7 +45,6 @@ class ConfigClient(BaseClient):
|
|
|
50
45
|
output_queue = config_response_queue
|
|
51
46
|
|
|
52
47
|
super(ConfigClient, self).__init__(
|
|
53
|
-
log_level=log_level,
|
|
54
48
|
subscriber=subscriber,
|
|
55
49
|
input_queue=input_queue,
|
|
56
50
|
output_queue=output_queue,
|
{trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/document_embeddings_client.py
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
|
|
4
3
|
from .. schema import DocumentEmbeddingsRequest, DocumentEmbeddingsResponse
|
|
5
4
|
from .. schema import document_embeddings_request_queue
|
|
@@ -7,15 +6,11 @@ from .. schema import document_embeddings_response_queue
|
|
|
7
6
|
from . base import BaseClient
|
|
8
7
|
|
|
9
8
|
# Ugly
|
|
10
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
11
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
12
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
13
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
14
9
|
|
|
15
10
|
class DocumentEmbeddingsClient(BaseClient):
|
|
16
11
|
|
|
17
12
|
def __init__(
|
|
18
|
-
self,
|
|
13
|
+
self,
|
|
19
14
|
subscriber=None,
|
|
20
15
|
input_queue=None,
|
|
21
16
|
output_queue=None,
|
|
@@ -30,7 +25,6 @@ class DocumentEmbeddingsClient(BaseClient):
|
|
|
30
25
|
output_queue = document_embeddings_response_queue
|
|
31
26
|
|
|
32
27
|
super(DocumentEmbeddingsClient, self).__init__(
|
|
33
|
-
log_level=log_level,
|
|
34
28
|
subscriber=subscriber,
|
|
35
29
|
input_queue=input_queue,
|
|
36
30
|
output_queue=output_queue,
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
|
|
4
3
|
from .. schema import DocumentRagQuery, DocumentRagResponse
|
|
5
4
|
from .. schema import document_rag_request_queue, document_rag_response_queue
|
|
6
5
|
from . base import BaseClient
|
|
7
6
|
|
|
8
7
|
# Ugly
|
|
9
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
10
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
11
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
12
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
13
8
|
|
|
14
9
|
class DocumentRagClient(BaseClient):
|
|
15
10
|
|
|
16
11
|
def __init__(
|
|
17
12
|
self,
|
|
18
|
-
log_level=ERROR,
|
|
19
13
|
subscriber=None,
|
|
20
14
|
input_queue=None,
|
|
21
15
|
output_queue=None,
|
|
@@ -30,7 +24,6 @@ class DocumentRagClient(BaseClient):
|
|
|
30
24
|
output_queue = document_rag_response_queue
|
|
31
25
|
|
|
32
26
|
super(DocumentRagClient, self).__init__(
|
|
33
|
-
log_level=log_level,
|
|
34
27
|
subscriber=subscriber,
|
|
35
28
|
input_queue=input_queue,
|
|
36
29
|
output_queue=output_queue,
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
|
|
2
|
-
from pulsar.schema import JsonSchema
|
|
3
2
|
from .. schema import EmbeddingsRequest, EmbeddingsResponse
|
|
4
3
|
from . base import BaseClient
|
|
5
4
|
|
|
6
|
-
import _pulsar
|
|
7
5
|
|
|
8
6
|
# Ugly
|
|
9
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
10
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
11
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
12
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
13
7
|
|
|
14
8
|
class EmbeddingsClient(BaseClient):
|
|
15
9
|
|
|
16
10
|
def __init__(
|
|
17
|
-
self,
|
|
11
|
+
self,
|
|
18
12
|
input_queue=None,
|
|
19
13
|
output_queue=None,
|
|
20
14
|
subscriber=None,
|
|
@@ -23,7 +17,6 @@ class EmbeddingsClient(BaseClient):
|
|
|
23
17
|
):
|
|
24
18
|
|
|
25
19
|
super(EmbeddingsClient, self).__init__(
|
|
26
|
-
log_level=log_level,
|
|
27
20
|
subscriber=subscriber,
|
|
28
21
|
input_queue=input_queue,
|
|
29
22
|
output_queue=output_queue,
|
{trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/graph_embeddings_client.py
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
|
|
4
3
|
from .. schema import GraphEmbeddingsRequest, GraphEmbeddingsResponse
|
|
5
4
|
from .. schema import graph_embeddings_request_queue
|
|
@@ -7,15 +6,11 @@ from .. schema import graph_embeddings_response_queue
|
|
|
7
6
|
from . base import BaseClient
|
|
8
7
|
|
|
9
8
|
# Ugly
|
|
10
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
11
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
12
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
13
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
14
9
|
|
|
15
10
|
class GraphEmbeddingsClient(BaseClient):
|
|
16
11
|
|
|
17
12
|
def __init__(
|
|
18
|
-
self,
|
|
13
|
+
self,
|
|
19
14
|
subscriber=None,
|
|
20
15
|
input_queue=None,
|
|
21
16
|
output_queue=None,
|
|
@@ -30,7 +25,6 @@ class GraphEmbeddingsClient(BaseClient):
|
|
|
30
25
|
output_queue = graph_embeddings_response_queue
|
|
31
26
|
|
|
32
27
|
super(GraphEmbeddingsClient, self).__init__(
|
|
33
|
-
log_level=log_level,
|
|
34
28
|
subscriber=subscriber,
|
|
35
29
|
input_queue=input_queue,
|
|
36
30
|
output_queue=output_queue,
|
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
|
|
4
3
|
from .. schema import GraphRagQuery, GraphRagResponse
|
|
5
4
|
from .. schema import graph_rag_request_queue, graph_rag_response_queue
|
|
6
5
|
from . base import BaseClient
|
|
7
6
|
|
|
8
7
|
# Ugly
|
|
9
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
10
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
11
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
12
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
13
8
|
|
|
14
9
|
class GraphRagClient(BaseClient):
|
|
15
10
|
|
|
16
11
|
def __init__(
|
|
17
12
|
self,
|
|
18
|
-
log_level=ERROR,
|
|
19
13
|
subscriber=None,
|
|
20
14
|
input_queue=None,
|
|
21
15
|
output_queue=None,
|
|
@@ -30,7 +24,6 @@ class GraphRagClient(BaseClient):
|
|
|
30
24
|
output_queue = graph_rag_response_queue
|
|
31
25
|
|
|
32
26
|
super(GraphRagClient, self).__init__(
|
|
33
|
-
log_level=log_level,
|
|
34
27
|
subscriber=subscriber,
|
|
35
28
|
input_queue=input_queue,
|
|
36
29
|
output_queue=output_queue,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
|
|
4
3
|
from .. schema import TextCompletionRequest, TextCompletionResponse
|
|
5
4
|
from .. schema import text_completion_request_queue
|
|
@@ -8,15 +7,11 @@ from . base import BaseClient
|
|
|
8
7
|
from .. exceptions import LlmError
|
|
9
8
|
|
|
10
9
|
# Ugly
|
|
11
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
12
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
13
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
14
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
15
10
|
|
|
16
11
|
class LlmClient(BaseClient):
|
|
17
12
|
|
|
18
13
|
def __init__(
|
|
19
|
-
self,
|
|
14
|
+
self,
|
|
20
15
|
subscriber=None,
|
|
21
16
|
input_queue=None,
|
|
22
17
|
output_queue=None,
|
|
@@ -28,7 +23,6 @@ class LlmClient(BaseClient):
|
|
|
28
23
|
if output_queue is None: output_queue = text_completion_response_queue
|
|
29
24
|
|
|
30
25
|
super(LlmClient, self).__init__(
|
|
31
|
-
log_level=log_level,
|
|
32
26
|
subscriber=subscriber,
|
|
33
27
|
input_queue=input_queue,
|
|
34
28
|
output_queue=output_queue,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
import json
|
|
4
3
|
import dataclasses
|
|
5
4
|
|
|
@@ -9,10 +8,6 @@ from .. schema import prompt_response_queue
|
|
|
9
8
|
from . base import BaseClient
|
|
10
9
|
|
|
11
10
|
# Ugly
|
|
12
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
13
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
14
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
15
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
16
11
|
|
|
17
12
|
@dataclasses.dataclass
|
|
18
13
|
class Definition:
|
|
@@ -34,7 +29,7 @@ class Topic:
|
|
|
34
29
|
class PromptClient(BaseClient):
|
|
35
30
|
|
|
36
31
|
def __init__(
|
|
37
|
-
self,
|
|
32
|
+
self,
|
|
38
33
|
subscriber=None,
|
|
39
34
|
input_queue=None,
|
|
40
35
|
output_queue=None,
|
|
@@ -49,7 +44,6 @@ class PromptClient(BaseClient):
|
|
|
49
44
|
output_queue = prompt_response_queue
|
|
50
45
|
|
|
51
46
|
super(PromptClient, self).__init__(
|
|
52
|
-
log_level=log_level,
|
|
53
47
|
subscriber=subscriber,
|
|
54
48
|
input_queue=input_queue,
|
|
55
49
|
output_queue=output_queue,
|
{trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/row_embeddings_client.py
RENAMED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
import _pulsar
|
|
3
2
|
|
|
4
3
|
from .. schema import RowEmbeddingsRequest, RowEmbeddingsResponse
|
|
5
4
|
from .. schema import row_embeddings_request_queue
|
|
@@ -7,15 +6,11 @@ from .. schema import row_embeddings_response_queue
|
|
|
7
6
|
from . base import BaseClient
|
|
8
7
|
|
|
9
8
|
# Ugly
|
|
10
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
11
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
12
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
13
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
14
9
|
|
|
15
10
|
class RowEmbeddingsClient(BaseClient):
|
|
16
11
|
|
|
17
12
|
def __init__(
|
|
18
|
-
self,
|
|
13
|
+
self,
|
|
19
14
|
subscriber=None,
|
|
20
15
|
input_queue=None,
|
|
21
16
|
output_queue=None,
|
|
@@ -30,7 +25,6 @@ class RowEmbeddingsClient(BaseClient):
|
|
|
30
25
|
output_queue = row_embeddings_response_queue
|
|
31
26
|
|
|
32
27
|
super(RowEmbeddingsClient, self).__init__(
|
|
33
|
-
log_level=log_level,
|
|
34
28
|
subscriber=subscriber,
|
|
35
29
|
input_queue=input_queue,
|
|
36
30
|
output_queue=output_queue,
|
{trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/triples_query_client.py
RENAMED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
|
|
3
|
-
import _pulsar
|
|
4
3
|
|
|
5
4
|
from .. schema import TriplesQueryRequest, TriplesQueryResponse, Term, IRI, LITERAL
|
|
6
5
|
from .. schema import triples_request_queue
|
|
@@ -8,15 +7,11 @@ from .. schema import triples_response_queue
|
|
|
8
7
|
from . base import BaseClient
|
|
9
8
|
|
|
10
9
|
# Ugly
|
|
11
|
-
ERROR=_pulsar.LoggerLevel.Error
|
|
12
|
-
WARN=_pulsar.LoggerLevel.Warn
|
|
13
|
-
INFO=_pulsar.LoggerLevel.Info
|
|
14
|
-
DEBUG=_pulsar.LoggerLevel.Debug
|
|
15
10
|
|
|
16
11
|
class TriplesQueryClient(BaseClient):
|
|
17
12
|
|
|
18
13
|
def __init__(
|
|
19
|
-
self,
|
|
14
|
+
self,
|
|
20
15
|
subscriber=None,
|
|
21
16
|
input_queue=None,
|
|
22
17
|
output_queue=None,
|
|
@@ -31,7 +26,6 @@ class TriplesQueryClient(BaseClient):
|
|
|
31
26
|
output_queue = triples_response_queue
|
|
32
27
|
|
|
33
28
|
super(TriplesQueryClient, self).__init__(
|
|
34
|
-
log_level=log_level,
|
|
35
29
|
subscriber=subscriber,
|
|
36
30
|
input_queue=input_queue,
|
|
37
31
|
output_queue=output_queue,
|
|
@@ -6,7 +6,7 @@ from .base import MessageTranslator
|
|
|
6
6
|
class AgentRequestTranslator(MessageTranslator):
|
|
7
7
|
"""Translator for AgentRequest schema objects"""
|
|
8
8
|
|
|
9
|
-
def
|
|
9
|
+
def decode(self, data: Dict[str, Any]) -> AgentRequest:
|
|
10
10
|
return AgentRequest(
|
|
11
11
|
question=data["question"],
|
|
12
12
|
state=data.get("state", None),
|
|
@@ -26,7 +26,7 @@ class AgentRequestTranslator(MessageTranslator):
|
|
|
26
26
|
expected_siblings=data.get("expected_siblings", 0),
|
|
27
27
|
)
|
|
28
28
|
|
|
29
|
-
def
|
|
29
|
+
def encode(self, obj: AgentRequest) -> Dict[str, Any]:
|
|
30
30
|
return {
|
|
31
31
|
"question": obj.question,
|
|
32
32
|
"state": obj.state,
|
|
@@ -50,10 +50,10 @@ class AgentRequestTranslator(MessageTranslator):
|
|
|
50
50
|
class AgentResponseTranslator(MessageTranslator):
|
|
51
51
|
"""Translator for AgentResponse schema objects"""
|
|
52
52
|
|
|
53
|
-
def
|
|
53
|
+
def decode(self, data: Dict[str, Any]) -> AgentResponse:
|
|
54
54
|
raise NotImplementedError("Response translation to Pulsar not typically needed")
|
|
55
55
|
|
|
56
|
-
def
|
|
56
|
+
def encode(self, obj: AgentResponse) -> Dict[str, Any]:
|
|
57
57
|
result = {}
|
|
58
58
|
|
|
59
59
|
if obj.chunk_type:
|
|
@@ -81,7 +81,7 @@ class AgentResponseTranslator(MessageTranslator):
|
|
|
81
81
|
|
|
82
82
|
return result
|
|
83
83
|
|
|
84
|
-
def
|
|
84
|
+
def encode_with_completion(self, obj: AgentResponse) -> Tuple[Dict[str, Any], bool]:
|
|
85
85
|
"""Returns (response_dict, is_final)"""
|
|
86
86
|
is_final = getattr(obj, 'end_of_dialog', False)
|
|
87
|
-
return self.
|
|
87
|
+
return self.encode(obj), is_final
|