h-message-bus 0.0.12__py3-none-any.whl → 0.0.14__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.
- h_message_bus/__init__.py +2 -1
- h_message_bus/domain/models/vector_query_answer.py +22 -0
- h_message_bus/domain/request_messages/vector_query_collection_response_message.py +16 -14
- {h_message_bus-0.0.12.dist-info → h_message_bus-0.0.14.dist-info}/METADATA +1 -1
- {h_message_bus-0.0.12.dist-info → h_message_bus-0.0.14.dist-info}/RECORD +7 -6
- {h_message_bus-0.0.12.dist-info → h_message_bus-0.0.14.dist-info}/WHEEL +0 -0
- {h_message_bus-0.0.12.dist-info → h_message_bus-0.0.14.dist-info}/top_level.txt +0 -0
h_message_bus/__init__.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
from .adapters.nats_publisher_adapter import NatsPublisherAdapter
|
2
2
|
from .adapters.nats_subscriber_adapter import NatsSubscriberAdapter
|
3
3
|
from .application.message_processor import MessageProcessor
|
4
|
+
from .domain.models.hai_message import HaiMessage
|
4
5
|
from .infrastructure.nats_client_repository import NatsClientRepository
|
5
6
|
from .infrastructure.nats_config import NatsConfig
|
6
|
-
|
7
|
+
|
7
8
|
|
8
9
|
|
9
10
|
__all__ = ['NatsConfig', 'HaiMessage', 'MessageProcessor', 'NatsClientRepository', 'NatsSubscriberAdapter', 'NatsPublisherAdapter']
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
|
3
|
+
|
4
|
+
@dataclass
|
5
|
+
class VectorQueryAnswer:
|
6
|
+
text: str
|
7
|
+
dimension: str
|
8
|
+
|
9
|
+
@classmethod
|
10
|
+
def from_dict(cls, data: dict) -> 'VectorQueryAnswer':
|
11
|
+
"""Create an instance from a dictionary."""
|
12
|
+
return cls(
|
13
|
+
text=data.get('text', ''),
|
14
|
+
dimension=data.get('dimension', ''),
|
15
|
+
)
|
16
|
+
|
17
|
+
def to_dict(self) -> dict:
|
18
|
+
"""Convert instance to a dictionary."""
|
19
|
+
return {
|
20
|
+
'text': self.text,
|
21
|
+
'dimension': self.dimension,
|
22
|
+
}
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
import json
|
2
|
+
from typing import Type, TypeVar, Dict, Any, List
|
2
3
|
|
3
4
|
from ..models.request_message_topic import RequestMessageTopic
|
5
|
+
from ..models.vector_query_answer import VectorQueryAnswer
|
4
6
|
from ...domain.models.hai_message import HaiMessage
|
5
7
|
|
6
8
|
T = TypeVar('T', bound='HaiMessage')
|
@@ -14,32 +16,32 @@ class VectorQueryCollectionResponseMessage(HaiMessage):
|
|
14
16
|
return super().create(topic=topic, payload=payload)
|
15
17
|
|
16
18
|
@classmethod
|
17
|
-
def create_message(cls,
|
19
|
+
def create_message(cls, result: List[dict[str, str]]) -> 'VectorQueryCollectionResponseMessage':
|
18
20
|
"""Create a message requesting Twitter user data"""
|
21
|
+
result_list = json.dumps(result)
|
19
22
|
return cls.create(
|
20
23
|
topic=RequestMessageTopic.AI_VECTORS_QUERY_RESPONSE,
|
21
24
|
payload={
|
22
|
-
"
|
23
|
-
"results": results
|
25
|
+
"result": result_list,
|
24
26
|
},
|
25
27
|
)
|
26
28
|
|
27
29
|
@property
|
28
|
-
def
|
29
|
-
"""Returns the dimensions from the message payload"""
|
30
|
-
return self.payload.get("dimensions", [])
|
31
|
-
|
32
|
-
@property
|
33
|
-
def results(self) -> list[str]:
|
30
|
+
def results(self) -> list[VectorQueryAnswer]:
|
34
31
|
"""Returns the results from the message payload"""
|
35
|
-
|
32
|
+
results = self.payload.get("result", "")
|
33
|
+
meta_dict = json.loads(results)
|
34
|
+
response_list = []
|
35
|
+
for meta in meta_dict:
|
36
|
+
response_list.append(VectorQueryAnswer.from_dict(meta))
|
37
|
+
return response_list
|
36
38
|
|
37
39
|
@classmethod
|
38
40
|
def from_hai_message(cls, message: HaiMessage) -> 'VectorQueryCollectionResponseMessage':
|
39
41
|
# Extract necessary fields from the message payload
|
40
42
|
payload = message.payload
|
41
|
-
|
43
|
+
result = payload.get("result", "")
|
44
|
+
result_list = json.loads(result)
|
42
45
|
return cls.create_message(
|
43
|
-
|
44
|
-
results=payload.get('results', [])
|
46
|
+
result=result_list
|
45
47
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
h_message_bus/__init__.py,sha256=
|
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
5
|
h_message_bus/adapters/nats_publisher_adapter.py,sha256=D2IV4eZyclQUB9ZU8WL0yvtTMTqxyB07wum6INeN3M8,1770
|
@@ -15,18 +15,19 @@ h_message_bus/domain/models/event_message_topic.py,sha256=fSjRMBwMD2RE9GBUud38XM
|
|
15
15
|
h_message_bus/domain/models/hai_message.py,sha256=b5CfX7hi5uNq77IVnZzEi9iotc4b_U2MNYwV6JY7JcU,2146
|
16
16
|
h_message_bus/domain/models/request_message_topic.py,sha256=5wCJzOFQjHG5bwlNbQzmMAFpVLZYPdPcKTXQMsAjC5M,1132
|
17
17
|
h_message_bus/domain/models/vector_collection_metadata.py,sha256=fSy3ZQ-zkYISTpc-_M6XWf1JkufVAlzlS2ZT60TzA2s,891
|
18
|
+
h_message_bus/domain/models/vector_query_answer.py,sha256=V1JR5Di7kIVbRF_eq2uPOhDnkZpQvo9pxD41V7MNV7Q,551
|
18
19
|
h_message_bus/domain/request_messages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
20
|
h_message_bus/domain/request_messages/twitter_get_user_request_message.py,sha256=BX-ytvnEzL9u1Yks5iXIx60Hmv3UP7asOG2uYA0mfgE,1212
|
20
21
|
h_message_bus/domain/request_messages/twitter_get_user_response_message.py,sha256=qO1cLtEmZyddv5pXHNgpnpO5t3Oex8cOG0hjGhOfru8,3302
|
21
22
|
h_message_bus/domain/request_messages/vector_query_collection_request_message.py,sha256=6zne_IFs4aHZ_hJqbXGAaNU8PMilSVKSAg5G_jzane0,1803
|
22
|
-
h_message_bus/domain/request_messages/vector_query_collection_response_message.py,sha256=
|
23
|
+
h_message_bus/domain/request_messages/vector_query_collection_response_message.py,sha256=8TtLrgxnQj3w7OqEzegykCfk2aobGVJySxiWRgbIfeQ,1771
|
23
24
|
h_message_bus/domain/request_messages/vector_read_metadata_request_message.py,sha256=l321y6ffLOvGESRDalBXtzcOG4qq_iy3a_j4uZ_R5KY,897
|
24
25
|
h_message_bus/domain/request_messages/vector_read_metadata_response_message.py,sha256=ecsSiE-0Uar3tqDtwvPGyu352nuW9FDIqwAjQvnPHDI,1651
|
25
26
|
h_message_bus/domain/request_messages/vector_save_request_message.py,sha256=Jd52Kc0OLsPLphfZtTesK6J1KqctC7Vm_0lmVxd99Ss,2098
|
26
27
|
h_message_bus/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
27
28
|
h_message_bus/infrastructure/nats_client_repository.py,sha256=lAapNaL0rqBr-9KaHcexuo5XLmSWRWspkJWXS9dMqPU,3371
|
28
29
|
h_message_bus/infrastructure/nats_config.py,sha256=Yzqqd1bCfmUv_4FOnA1dvqIpakzV0BUL2_nXQcndWvo,1304
|
29
|
-
h_message_bus-0.0.
|
30
|
-
h_message_bus-0.0.
|
31
|
-
h_message_bus-0.0.
|
32
|
-
h_message_bus-0.0.
|
30
|
+
h_message_bus-0.0.14.dist-info/METADATA,sha256=JZp3eFWrSFtJ7GVTvRQPKjEFw6WV5b5cWgkIuucwjsE,8834
|
31
|
+
h_message_bus-0.0.14.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
32
|
+
h_message_bus-0.0.14.dist-info/top_level.txt,sha256=BArjhm_lwFR9yJJEIf-LT_X64psuLkXFdbpQRJUreFE,23
|
33
|
+
h_message_bus-0.0.14.dist-info/RECORD,,
|
File without changes
|
File without changes
|