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.
Files changed (163) hide show
  1. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/PKG-INFO +1 -1
  2. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/__init__.py +1 -1
  3. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/async_processor.py +4 -13
  4. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/flow_processor.py +0 -2
  5. trustgraph_base-2.2.15/trustgraph/base/pubsub.py +72 -0
  6. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/pulsar_backend.py +28 -19
  7. trustgraph_base-2.2.15/trustgraph/base_version.py +1 -0
  8. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/agent_client.py +1 -7
  9. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/base.py +2 -12
  10. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/config_client.py +1 -7
  11. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/document_embeddings_client.py +1 -7
  12. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/document_rag_client.py +0 -7
  13. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/embeddings_client.py +1 -8
  14. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/graph_embeddings_client.py +1 -7
  15. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/graph_rag_client.py +0 -7
  16. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/llm_client.py +1 -7
  17. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/prompt_client.py +1 -7
  18. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/row_embeddings_client.py +1 -7
  19. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/triples_query_client.py +1 -7
  20. trustgraph_base-2.2.15/trustgraph/log_level.py +12 -0
  21. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/agent.py +6 -6
  22. trustgraph_base-2.2.15/trustgraph/messaging/translators/base.py +46 -0
  23. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/collection.py +4 -4
  24. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/config.py +6 -6
  25. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/diagnosis.py +6 -6
  26. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/document_loading.py +8 -8
  27. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/embeddings.py +6 -6
  28. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/embeddings_query.py +19 -19
  29. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/flow.py +6 -6
  30. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/knowledge.py +12 -12
  31. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/library.py +13 -13
  32. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/metadata.py +6 -6
  33. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/nlp_query.py +6 -6
  34. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/primitives.py +28 -28
  35. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/prompt.py +6 -6
  36. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/retrieval.py +12 -12
  37. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/rows_query.py +6 -6
  38. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/structured_query.py +6 -6
  39. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/text_completion.py +6 -6
  40. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/tool.py +6 -6
  41. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/triples.py +13 -13
  42. trustgraph_base-2.2.15/trustgraph/schema/core/topic.py +26 -0
  43. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/document.py +0 -1
  44. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/embeddings.py +0 -1
  45. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/graph.py +0 -1
  46. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/knowledge.py +3 -7
  47. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/nlp.py +0 -1
  48. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/object.py +0 -1
  49. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/rows.py +0 -1
  50. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/structured.py +0 -1
  51. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/agent.py +0 -1
  52. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/collection.py +3 -7
  53. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/config.py +4 -10
  54. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/flow.py +3 -7
  55. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/library.py +3 -7
  56. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/llm.py +0 -1
  57. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/lookup.py +0 -1
  58. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/nlp_query.py +0 -1
  59. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/prompt.py +0 -1
  60. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/query.py +5 -13
  61. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/retrieval.py +0 -1
  62. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/rows_query.py +0 -1
  63. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/structured_query.py +0 -1
  64. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/PKG-INFO +1 -1
  65. trustgraph_base-2.2.14/trustgraph/base/pubsub.py +0 -110
  66. trustgraph_base-2.2.14/trustgraph/base_version.py +0 -1
  67. trustgraph_base-2.2.14/trustgraph/log_level.py +0 -20
  68. trustgraph_base-2.2.14/trustgraph/messaging/translators/base.py +0 -43
  69. trustgraph_base-2.2.14/trustgraph/schema/core/topic.py +0 -23
  70. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/README.md +0 -0
  71. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/pyproject.toml +0 -0
  72. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/setup.cfg +0 -0
  73. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/__init__.py +0 -0
  74. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/api.py +0 -0
  75. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_bulk_client.py +0 -0
  76. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_flow.py +0 -0
  77. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_metrics.py +0 -0
  78. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/async_socket_client.py +0 -0
  79. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/bulk_client.py +0 -0
  80. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/collection.py +0 -0
  81. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/config.py +0 -0
  82. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/exceptions.py +0 -0
  83. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/explainability.py +0 -0
  84. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/flow.py +0 -0
  85. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/knowledge.py +0 -0
  86. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/library.py +0 -0
  87. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/metrics.py +0 -0
  88. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/socket_client.py +0 -0
  89. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/api/types.py +0 -0
  90. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/agent_client.py +0 -0
  91. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/agent_service.py +0 -0
  92. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/backend.py +0 -0
  93. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/cassandra_config.py +0 -0
  94. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/chunking_service.py +0 -0
  95. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/collection_config_handler.py +0 -0
  96. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/consumer.py +0 -0
  97. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/consumer_spec.py +0 -0
  98. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/document_embeddings_client.py +0 -0
  99. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/document_embeddings_query_service.py +0 -0
  100. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/document_embeddings_store_service.py +0 -0
  101. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/dynamic_tool_service.py +0 -0
  102. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/embeddings_client.py +0 -0
  103. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/embeddings_service.py +0 -0
  104. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/flow.py +0 -0
  105. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_embeddings_client.py +0 -0
  106. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_embeddings_query_service.py +0 -0
  107. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_embeddings_store_service.py +0 -0
  108. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/graph_rag_client.py +0 -0
  109. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/llm_service.py +0 -0
  110. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/logging.py +0 -0
  111. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/metrics.py +0 -0
  112. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/parameter_spec.py +0 -0
  113. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/producer.py +0 -0
  114. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/producer_spec.py +0 -0
  115. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/prompt_client.py +0 -0
  116. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/publisher.py +0 -0
  117. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/request_response_spec.py +0 -0
  118. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/row_embeddings_query_client.py +0 -0
  119. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/spec.py +0 -0
  120. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/structured_query_client.py +0 -0
  121. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/subscriber.py +0 -0
  122. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/subscriber_spec.py +0 -0
  123. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/text_completion_client.py +0 -0
  124. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/tool_client.py +0 -0
  125. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/tool_service.py +0 -0
  126. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/tool_service_client.py +0 -0
  127. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/triples_client.py +0 -0
  128. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/triples_query_service.py +0 -0
  129. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/base/triples_store_service.py +0 -0
  130. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/clients/__init__.py +0 -0
  131. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/exceptions.py +0 -0
  132. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/__init__.py +0 -0
  133. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/defs.py +0 -0
  134. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/document.py +0 -0
  135. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/identifier.py +0 -0
  136. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/organization.py +0 -0
  137. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/knowledge/publication.py +0 -0
  138. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/__init__.py +0 -0
  139. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/registry.py +0 -0
  140. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/messaging/translators/__init__.py +0 -0
  141. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/objects/__init__.py +0 -0
  142. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/objects/field.py +0 -0
  143. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/objects/object.py +0 -0
  144. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/__init__.py +0 -0
  145. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/agent.py +0 -0
  146. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/namespaces.py +0 -0
  147. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/triples.py +0 -0
  148. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/uris.py +0 -0
  149. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/provenance/vocabulary.py +0 -0
  150. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/rdf.py +0 -0
  151. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/__init__.py +0 -0
  152. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/core/__init__.py +0 -0
  153. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/core/metadata.py +0 -0
  154. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/core/primitives.py +0 -0
  155. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/knowledge/__init__.py +0 -0
  156. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/__init__.py +0 -0
  157. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/diagnosis.py +0 -0
  158. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/storage.py +0 -0
  159. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph/schema/services/tool_service.py +0 -0
  160. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/SOURCES.txt +0 -0
  161. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/dependency_links.txt +0 -0
  162. {trustgraph_base-2.2.14 → trustgraph_base-2.2.15}/trustgraph_base.egg-info/requires.txt +0 -0
  163. {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.14
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
@@ -1,5 +1,5 @@
1
1
 
2
- from . pubsub import PulsarClient, get_pubsub
2
+ from . pubsub import get_pubsub, add_pubsub_args
3
3
  from . async_processor import AsyncProcessor
4
4
  from . consumer import Consumer
5
5
  from . producer import Producer
@@ -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 PulsarClient, get_pubsub
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 _pulsar.Interrupted:
227
- logger.info("Pulsar Interrupted.")
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
- # Pub/sub backend selection
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(
@@ -6,8 +6,6 @@
6
6
  import json
7
7
  import logging
8
8
 
9
- from pulsar.schema import JsonSchema
10
-
11
9
  from .. schema import Error
12
10
  from .. schema import config_request_queue, config_response_queue
13
11
  from .. schema import config_push_queue
@@ -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
- pulsar_msg = self._consumer.receive(timeout_millis=timeout_millis)
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, generic_topic: str) -> str:
243
+ def map_topic(self, queue_id: str) -> str:
241
244
  """
242
- Map generic topic format to Pulsar URI.
245
+ Map queue identifier to Pulsar URI.
243
246
 
244
- Format: qos/tenant/namespace/queue
245
- Example: q1/tg/flow/my-queue -> persistent://tg/flow/my-queue
247
+ Format: class:topicspace:topic
248
+ Example: flow:tg:text-completion-request -> persistent://tg/flow/text-completion-request
246
249
 
247
250
  Args:
248
- generic_topic: Generic topic string or already-formatted Pulsar URI
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 generic_topic:
255
- return generic_topic
257
+ if '://' in queue_id:
258
+ return queue_id
256
259
 
257
- parts = generic_topic.split('/', 3)
258
- if len(parts) != 4:
259
- raise ValueError(f"Invalid topic format: {generic_topic}, expected qos/tenant/namespace/queue")
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
- qos, tenant, namespace, queue = parts
267
+ cls, topicspace, topic = parts
262
268
 
263
- # Map QoS to persistence
264
- if qos == 'q0':
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(f"Invalid QoS level: {qos}, expected q0, q1, or q2")
275
+ raise ValueError(
276
+ f"Invalid queue class: {cls}, "
277
+ f"expected flow, request, response, or state"
278
+ )
270
279
 
271
- return f"{persistence}://{tenant}/{namespace}/{queue}"
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, log_level=ERROR,
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, log_level=ERROR,
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 pulsar.exceptions.Timeout:
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, log_level=ERROR,
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,
@@ -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, log_level=ERROR,
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, log_level=ERROR,
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,
@@ -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, log_level=ERROR,
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, log_level=ERROR,
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, log_level=ERROR,
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,
@@ -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, log_level=ERROR,
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,
@@ -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, log_level=ERROR,
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,
@@ -0,0 +1,12 @@
1
+
2
+ from enum import Enum
3
+
4
+
5
+ class LogLevel(Enum):
6
+ DEBUG = 'debug'
7
+ INFO = 'info'
8
+ WARN = 'warn'
9
+ ERROR = 'error'
10
+
11
+ def __str__(self):
12
+ return self.value
@@ -6,7 +6,7 @@ from .base import MessageTranslator
6
6
  class AgentRequestTranslator(MessageTranslator):
7
7
  """Translator for AgentRequest schema objects"""
8
8
 
9
- def to_pulsar(self, data: Dict[str, Any]) -> AgentRequest:
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 from_pulsar(self, obj: AgentRequest) -> Dict[str, Any]:
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 to_pulsar(self, data: Dict[str, Any]) -> AgentResponse:
53
+ def decode(self, data: Dict[str, Any]) -> AgentResponse:
54
54
  raise NotImplementedError("Response translation to Pulsar not typically needed")
55
55
 
56
- def from_pulsar(self, obj: AgentResponse) -> Dict[str, Any]:
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 from_response_with_completion(self, obj: AgentResponse) -> Tuple[Dict[str, Any], bool]:
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.from_pulsar(obj), is_final
87
+ return self.encode(obj), is_final