h-message-bus 0.0.28__py3-none-any.whl → 0.0.29__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.
@@ -0,0 +1,69 @@
1
+ from typing import TypeVar, Dict, Any, Type, Optional
2
+
3
+ from ..models.request_message_topic import RequestMessageTopic
4
+ from ...domain.models.hai_message import HaiMessage
5
+
6
+ T = TypeVar('T', bound='HaiMessage')
7
+
8
+ class GraphNodeUpdateResponseMessage(HaiMessage):
9
+ """Message indicating a node was successfully added to the graph"""
10
+
11
+ @classmethod
12
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
13
+ """Create a message - inherited from HaiMessage"""
14
+ return super().create(topic=topic, payload=payload)
15
+
16
+ @classmethod
17
+ def create_message(cls, node_id: str, label: str, properties: dict = None,
18
+ description: str = None) -> 'GraphNodeUpdateResponseMessage':
19
+ """Create a message confirming a node was added"""
20
+ if properties is None:
21
+ properties = {}
22
+
23
+ return cls.create(
24
+ topic=RequestMessageTopic.GRAPH_NODE_UPDATE_RESPONSE,
25
+ payload={
26
+ "node_id": node_id,
27
+ "label": label,
28
+ "properties": properties,
29
+ "description": description,
30
+ "success": True
31
+ },
32
+ )
33
+
34
+ @property
35
+ def node_id(self) -> str:
36
+ """Get the node ID from the payload"""
37
+ return self.payload.get("node_id")
38
+
39
+ @property
40
+ def label(self) -> str:
41
+ """Get the label from the payload"""
42
+ return self.payload.get("label")
43
+
44
+ @property
45
+ def properties(self) -> dict:
46
+ """Get the properties from the payload"""
47
+ return self.payload.get("properties", {})
48
+
49
+ @property
50
+ def description(self) -> Optional[str]:
51
+ """Get the description from the payload"""
52
+ return self.payload.get("description")
53
+
54
+ @property
55
+ def success(self) -> bool:
56
+ """Check if the operation was successful"""
57
+ return self.payload.get("success", False)
58
+
59
+ @classmethod
60
+ def from_hai_message(cls, message: HaiMessage) -> 'GraphNodeUpdateResponseMessage':
61
+ # Extract the necessary fields from the message payload
62
+ payload = message.payload
63
+
64
+ return cls.create_message(
65
+ node_id=payload.get("node_id", ''),
66
+ label=payload.get("label", ''),
67
+ properties=payload.get("properties", {}),
68
+ description=payload.get("description")
69
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_message_bus
3
- Version: 0.0.28
3
+ Version: 0.0.29
4
4
  Summary: Message bus integration for HAI
5
5
  Author-email: shoebill <shoebill.hai@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -27,6 +27,7 @@ h_message_bus/domain/request_messages/graph_node_added_response_message.py,sha25
27
27
  h_message_bus/domain/request_messages/graph_node_get_request_message.py,sha256=G_JlCnwU6a9HEU0gFt8ilOwx1KF-FJC0EqpWw1C4km8,1302
28
28
  h_message_bus/domain/request_messages/graph_node_get_result_response_message.py,sha256=kzde_K65UezKm2NLSFehiLrDAVTHXZM9Gd-GDYUZ1dg,2457
29
29
  h_message_bus/domain/request_messages/graph_node_update_request_message.py,sha256=gNXcQmpPF6Ut6M8wtRx7Xi7XdpCT9ZJvqPzNoSdwUZQ,1977
30
+ h_message_bus/domain/request_messages/graph_node_update_response_message.py,sha256=Adm_4H9n1NliW4VqSjT8P_Bmi7l-Ktk1cTgqwLH74BM,2399
30
31
  h_message_bus/domain/request_messages/graph_nodes_by_property_request_message.py,sha256=L-oZfZqsI9DG-CFL0G7r-2A-6wTqFuMNkDww2JUR73s,1712
31
32
  h_message_bus/domain/request_messages/graph_nodes_by_property_response_message.py,sha256=UDCA769I14BNP2Qmfwg5c6m98nBNVSZ10Kpi8Z8AGAQ,3051
32
33
  h_message_bus/domain/request_messages/graph_query_request_message.py,sha256=UXs_m6pgPkYRSRHrhI-c3WAQ31Yj1idZBgavufm32s0,1635
@@ -50,7 +51,7 @@ h_message_bus/domain/request_messages/web_search_request_message.py,sha256=ZoB4i
50
51
  h_message_bus/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
52
  h_message_bus/infrastructure/nats_client_repository.py,sha256=bhaWRK94h2EmFIef2DALnoBJKnuTnx6-iU7IXO2S_EU,3642
52
53
  h_message_bus/infrastructure/nats_config.py,sha256=Yzqqd1bCfmUv_4FOnA1dvqIpakzV0BUL2_nXQcndWvo,1304
53
- h_message_bus-0.0.28.dist-info/METADATA,sha256=06OtbUo9hEtm70zCPjv1RcEK3cu06-s0CxmleGO3EEU,8834
54
- h_message_bus-0.0.28.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
55
- h_message_bus-0.0.28.dist-info/top_level.txt,sha256=BArjhm_lwFR9yJJEIf-LT_X64psuLkXFdbpQRJUreFE,23
56
- h_message_bus-0.0.28.dist-info/RECORD,,
54
+ h_message_bus-0.0.29.dist-info/METADATA,sha256=TuE20kbc6p0TNq_-xeMtoTQ5t95eSbO2Z-QjVGqSu18,8834
55
+ h_message_bus-0.0.29.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
56
+ h_message_bus-0.0.29.dist-info/top_level.txt,sha256=BArjhm_lwFR9yJJEIf-LT_X64psuLkXFdbpQRJUreFE,23
57
+ h_message_bus-0.0.29.dist-info/RECORD,,