2024-07-10 23:20:06 +01:00
|
|
|
|
2024-08-20 17:54:11 +01:00
|
|
|
from .. schema import EmbeddingsRequest, EmbeddingsResponse
|
2024-08-22 17:02:18 +01:00
|
|
|
from . base import BaseClient
|
|
|
|
|
|
2024-07-10 23:20:06 +01:00
|
|
|
|
|
|
|
|
# Ugly
|
|
|
|
|
|
2024-08-22 17:02:18 +01:00
|
|
|
class EmbeddingsClient(BaseClient):
|
2024-07-10 23:20:06 +01:00
|
|
|
|
|
|
|
|
def __init__(
|
Pub/sub abstraction: decouple from Pulsar (#751)
Remove Pulsar-specific concepts from application code so that
the pub/sub backend is swappable via configuration.
Rename translators:
- to_pulsar/from_pulsar → decode/encode across all translator
classes, dispatch handlers, and tests (55+ files)
- from_response_with_completion → encode_with_completion
- Remove pulsar.schema.Record from translator base class
Queue naming (CLASS:TOPICSPACE:TOPIC):
- Replace topic() helper with queue() using new format:
flow:tg:name, request:tg:name, response:tg:name, state:tg:name
- Queue class implies persistence/TTL (no QoS in names)
- Update Pulsar backend map_topic() to parse new format
- Librarian queues use flow class (persistent, for chunking)
- Config push uses state class (persistent, last-value)
- Remove 15 dead topic imports from schema files
- Update init_trustgraph.py namespace: config → state
Confine Pulsar to pulsar_backend.py:
- Delete legacy PulsarClient class from pubsub.py
- Move add_args to add_pubsub_args() with standalone flag
for CLI tools (defaults to localhost)
- PulsarBackendConsumer.receive() catches _pulsar.Timeout,
raises standard TimeoutError
- Remove Pulsar imports from: async_processor, flow_processor,
log_level, all 11 client files, 4 storage writers, gateway
service, gateway config receiver
- Remove log_level/LoggerLevel from client API
- Rewrite tg-monitor-prompts to use backend abstraction
- Update tg-dump-queues to use add_pubsub_args
Also: pubsub-abstraction.md tech spec covering problem statement,
design goals, as-is requirements, candidate broker assessment,
approach, and implementation order.
2026-04-01 20:16:53 +01:00
|
|
|
self,
|
2024-08-05 21:48:52 +01:00
|
|
|
input_queue=None,
|
|
|
|
|
output_queue=None,
|
|
|
|
|
subscriber=None,
|
2024-07-10 23:20:06 +01:00
|
|
|
pulsar_host="pulsar://pulsar:6650",
|
2025-02-15 11:22:48 +00:00
|
|
|
pulsar_api_key=None,
|
2024-07-10 23:20:06 +01:00
|
|
|
):
|
|
|
|
|
|
2024-08-22 17:02:18 +01:00
|
|
|
super(EmbeddingsClient, self).__init__(
|
|
|
|
|
subscriber=subscriber,
|
|
|
|
|
input_queue=input_queue,
|
|
|
|
|
output_queue=output_queue,
|
|
|
|
|
pulsar_host=pulsar_host,
|
2025-02-15 11:22:48 +00:00
|
|
|
pulsar_api_key=pulsar_api_key,
|
2024-08-22 17:02:18 +01:00
|
|
|
input_schema=EmbeddingsRequest,
|
|
|
|
|
output_schema=EmbeddingsResponse,
|
2024-07-10 23:20:06 +01:00
|
|
|
)
|
|
|
|
|
|
2024-08-25 23:57:30 +01:00
|
|
|
def request(self, text, timeout=300):
|
2024-08-22 17:02:18 +01:00
|
|
|
return self.call(text=text, timeout=timeout).vectors
|
2024-07-10 23:20:06 +01:00
|
|
|
|