h-message-bus 0.0.23__py3-none-any.whl → 0.0.25__py3-none-any.whl

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.
@@ -1,3 +1,4 @@
1
+ import asyncio
1
2
  from typing import Optional
2
3
 
3
4
  from ..application.message_publisher import MessagePublisher
@@ -23,14 +24,14 @@ class NatsPublisherAdapter(MessagePublisher):
23
24
  def __init__(self, nats_client: NatsClientRepository):
24
25
  self.nats_client = nats_client
25
26
 
26
- async def publish(self, message: HaiMessage):
27
+ async def publish(self, message: HaiMessage, wait_time: float = 0.1):
27
28
  """Publish a message to NATS."""
28
29
  try:
29
-
30
30
  await self.nats_client.publish(
31
31
  message.topic,
32
32
  message.to_json().encode()
33
33
  )
34
+ await asyncio.sleep(wait_time)
34
35
  except Exception as e:
35
36
  print(f"Failed to publish message: {e}")
36
37
  return
@@ -14,12 +14,13 @@ class VectorSaveRequestMessage(HaiMessage):
14
14
  return super().create(topic=topic, payload=payload)
15
15
 
16
16
  @classmethod
17
- def create_message(cls, collection_name: str, document_id: str, content: str, metadata: dict[str,str]) -> 'VectorSaveRequestMessage':
17
+ def create_message(cls, collection_name: str, collection_metadata: dict[str,str], document_id: str, content: str, metadata: dict[str,str]) -> 'VectorSaveRequestMessage':
18
18
  """Create a message requesting Twitter user data"""
19
19
  return cls.create(
20
20
  topic=RequestMessageTopic.VECTORS_SAVE,
21
21
  payload={
22
22
  "collection_name": collection_name,
23
+ "collection_metadata": collection_metadata,
23
24
  "document_id": document_id,
24
25
  "content": content,
25
26
  "metadata": metadata
@@ -31,6 +32,11 @@ class VectorSaveRequestMessage(HaiMessage):
31
32
  """Get the collection name from the payload"""
32
33
  return self.payload.get("collection_name")
33
34
 
35
+ @property
36
+ def collection_metadata(self) -> dict[str, str]:
37
+ """Get the collection name from the payload"""
38
+ return self.payload.get("collection_metadata")
39
+
34
40
  @property
35
41
  def document_id(self) -> str:
36
42
  """Get the document ID from the payload"""
@@ -53,6 +59,7 @@ class VectorSaveRequestMessage(HaiMessage):
53
59
 
54
60
  return cls.create_message(
55
61
  collection_name=payload.get("collection_name", ''),
62
+ collection_metadata=payload.get("collection_metadata", {}),
56
63
  document_id=payload.get("document_id", ''),
57
64
  content=payload.get("content", ''),
58
65
  metadata=payload.get("metadata", {})
@@ -54,9 +54,7 @@ class NatsClientRepository:
54
54
  await self.connect()
55
55
 
56
56
  try:
57
- result = await self.client.publish(subject, payload)
58
- print(f"Message published: {result}")
59
- self.logger.info(f"Successfully published message to subject: {subject}")
57
+ await self.client.publish(subject, payload)
60
58
  except Exception as e:
61
59
  print(f"Failed to publish message: {e}")
62
60
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_message_bus
3
- Version: 0.0.23
3
+ Version: 0.0.25
4
4
  Summary: Message bus integration for HAI
5
5
  Author-email: shoebill <shoebill.hai@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -2,7 +2,7 @@ __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  h_message_bus/__init__.py,sha256=T_07sHtXLlRuLwK-BRVfFIIOGc48TKbtVLvKtIw2K5U,516
3
3
  h_message_bus/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  h_message_bus/adapters/nats_message_adapter.py,sha256=-hzx0UJmKJT4VWfRA_zVT68hddl9dejvUiSdLU1rY-w,1378
5
- h_message_bus/adapters/nats_publisher_adapter.py,sha256=kIh7J-eS-MPvfGsnmdGwsWYfLgepBC99v5d04KXyOaE,1900
5
+ h_message_bus/adapters/nats_publisher_adapter.py,sha256=EgrGioGuZfLpJsb5wiialMGMe8E4oUktS8zMdGri3Lc,1982
6
6
  h_message_bus/adapters/nats_subscriber_adapter.py,sha256=UJN2Es7hokbO5YsSUAf0KQ2B15QcGzGtQx-G1S3iQWQ,2105
7
7
  h_message_bus/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  h_message_bus/application/message_processor.py,sha256=1vdVfPn1BUDmswJ-Y5aS-YDbLSizrjX6_CMIBa5SGjc,734
@@ -26,13 +26,13 @@ h_message_bus/domain/request_messages/vector_query_collection_request_message.py
26
26
  h_message_bus/domain/request_messages/vector_query_collection_response_message.py,sha256=Q589JT_QE-oVsTh1GEmK__3Hct7ijfM1UTcPi0YTGn8,1767
27
27
  h_message_bus/domain/request_messages/vector_read_metadata_request_message.py,sha256=P9t6pcynS112F9_Jmbvw8wlfXhs5NOnV48SUVq92xt8,873
28
28
  h_message_bus/domain/request_messages/vector_read_metadata_response_message.py,sha256=G2TDV_lbUM7RVrvEaYQAP-3I36J0pqLXqxnqwVBMWhk,1648
29
- h_message_bus/domain/request_messages/vector_save_request_message.py,sha256=NvRdSUtE-X3sQTfJg7_QLic3PtbpgYUH2lQrNSC1ggg,2115
29
+ h_message_bus/domain/request_messages/vector_save_request_message.py,sha256=XqrdO4_JZ9NoSkcDYLIevUIdkX9BwY-zB24v37WQrZQ,2468
30
30
  h_message_bus/domain/request_messages/web_get_docs_request_message.py,sha256=MkJySkRBlQ2CacMoPCd3FwXQt1tVVFdrZKxsA6yMsrk,1576
31
31
  h_message_bus/domain/request_messages/web_search_request_message.py,sha256=ZoB4idrFEs7HQ6IRxmwKrrfHWe3GlGF4LuOK68K5NEM,1000
32
32
  h_message_bus/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- h_message_bus/infrastructure/nats_client_repository.py,sha256=vfI7z0UYZ00qAhMDQNKZshOhyAEz7P8uC_edDH6Ox7M,3789
33
+ h_message_bus/infrastructure/nats_client_repository.py,sha256=bhaWRK94h2EmFIef2DALnoBJKnuTnx6-iU7IXO2S_EU,3642
34
34
  h_message_bus/infrastructure/nats_config.py,sha256=Yzqqd1bCfmUv_4FOnA1dvqIpakzV0BUL2_nXQcndWvo,1304
35
- h_message_bus-0.0.23.dist-info/METADATA,sha256=P5izMs30tx2CRmfoUgsSeFwd6Zp9ufEewu9uayobQ3w,8834
36
- h_message_bus-0.0.23.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
37
- h_message_bus-0.0.23.dist-info/top_level.txt,sha256=BArjhm_lwFR9yJJEIf-LT_X64psuLkXFdbpQRJUreFE,23
38
- h_message_bus-0.0.23.dist-info/RECORD,,
35
+ h_message_bus-0.0.25.dist-info/METADATA,sha256=HDtJGQGS7RGmPxAUajrlocNkPFgeKvL_5hDrrgTNe0g,8834
36
+ h_message_bus-0.0.25.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
37
+ h_message_bus-0.0.25.dist-info/top_level.txt,sha256=BArjhm_lwFR9yJJEIf-LT_X64psuLkXFdbpQRJUreFE,23
38
+ h_message_bus-0.0.25.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.1)
2
+ Generator: setuptools (80.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5