h-message-bus 0.0.39__py3-none-any.whl → 0.0.41__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.
Files changed (63) hide show
  1. h_message_bus/infrastructure/nats_client_repository.py +70 -54
  2. h_message_bus/infrastructure/nats_config.py +1 -1
  3. {h_message_bus-0.0.39.dist-info → h_message_bus-0.0.41.dist-info}/METADATA +106 -85
  4. h_message_bus-0.0.41.dist-info/RECORD +20 -0
  5. {h_message_bus-0.0.39.dist-info → h_message_bus-0.0.41.dist-info}/WHEEL +1 -1
  6. h_message_bus/domain/event_messages/__init__.py +0 -0
  7. h_message_bus/domain/models/event_message_topic.py +0 -20
  8. h_message_bus/domain/models/request_message_topic.py +0 -100
  9. h_message_bus/domain/models/twitter_message_metadata.py +0 -31
  10. h_message_bus/domain/models/twitter_user_metadata.py +0 -76
  11. h_message_bus/domain/models/vector_collection_metadata.py +0 -30
  12. h_message_bus/domain/models/vector_query_answer.py +0 -22
  13. h_message_bus/domain/request_messages/__init__.py +0 -0
  14. h_message_bus/domain/request_messages/graph_clear_request_message.py +0 -26
  15. h_message_bus/domain/request_messages/graph_get_all_request_message.py +0 -27
  16. h_message_bus/domain/request_messages/graph_get_all_result_response_message.py +0 -45
  17. h_message_bus/domain/request_messages/graph_node_add_request_message.py +0 -64
  18. h_message_bus/domain/request_messages/graph_node_added_response_message.py +0 -69
  19. h_message_bus/domain/request_messages/graph_node_get_request_message.py +0 -39
  20. h_message_bus/domain/request_messages/graph_node_get_result_response_message.py +0 -70
  21. h_message_bus/domain/request_messages/graph_node_update_request_message.py +0 -56
  22. h_message_bus/domain/request_messages/graph_node_update_response_message.py +0 -69
  23. h_message_bus/domain/request_messages/graph_nodes_by_property_request_message.py +0 -45
  24. h_message_bus/domain/request_messages/graph_nodes_by_property_response_message.py +0 -80
  25. h_message_bus/domain/request_messages/graph_query_operation_request_message.py +0 -114
  26. h_message_bus/domain/request_messages/graph_query_operation_response_message.py +0 -85
  27. h_message_bus/domain/request_messages/graph_query_request_message.py +0 -48
  28. h_message_bus/domain/request_messages/graph_relationship_added_request_message.py +0 -63
  29. h_message_bus/domain/request_messages/init_knowledgebase_request.py +0 -26
  30. h_message_bus/domain/request_messages/tg_message_request_message.py +0 -48
  31. h_message_bus/domain/request_messages/tg_user_message_reply_request_message.py +0 -56
  32. h_message_bus/domain/request_messages/tg_user_message_request_message.py +0 -93
  33. h_message_bus/domain/request_messages/twitter_follow_user_request_message.py +0 -40
  34. h_message_bus/domain/request_messages/twitter_follow_user_response_message.py +0 -43
  35. h_message_bus/domain/request_messages/twitter_get_tweet_request_message.py +0 -40
  36. h_message_bus/domain/request_messages/twitter_get_tweet_response_message.py +0 -54
  37. h_message_bus/domain/request_messages/twitter_get_user_request_message.py +0 -35
  38. h_message_bus/domain/request_messages/twitter_get_user_response_message.py +0 -96
  39. h_message_bus/domain/request_messages/twitter_get_users_request_message.py +0 -42
  40. h_message_bus/domain/request_messages/twitter_get_users_response_message.py +0 -44
  41. h_message_bus/domain/request_messages/twitter_home_timeline_request_message.py +0 -56
  42. h_message_bus/domain/request_messages/twitter_home_timeline_response_message.py +0 -74
  43. h_message_bus/domain/request_messages/twitter_post_tweet_request_message.py +0 -40
  44. h_message_bus/domain/request_messages/twitter_post_tweet_response_message.py +0 -47
  45. h_message_bus/domain/request_messages/twitter_quote_retweet_request_message.py +0 -48
  46. h_message_bus/domain/request_messages/twitter_quote_retweet_response_message.py +0 -55
  47. h_message_bus/domain/request_messages/twitter_reply_request_message.py +0 -48
  48. h_message_bus/domain/request_messages/twitter_reply_response_message.py +0 -54
  49. h_message_bus/domain/request_messages/twitter_retweet_request_message.py +0 -40
  50. h_message_bus/domain/request_messages/twitter_retweet_response_message.py +0 -43
  51. h_message_bus/domain/request_messages/twitter_search_request_message.py +0 -73
  52. h_message_bus/domain/request_messages/twitter_search_response_message.py +0 -73
  53. h_message_bus/domain/request_messages/twitter_user_tweets_request_message.py +0 -63
  54. h_message_bus/domain/request_messages/twitter_user_tweets_response_message.py +0 -89
  55. h_message_bus/domain/request_messages/vector_query_collection_request_message.py +0 -51
  56. h_message_bus/domain/request_messages/vector_query_collection_response_message.py +0 -47
  57. h_message_bus/domain/request_messages/vector_read_metadata_request_message.py +0 -25
  58. h_message_bus/domain/request_messages/vector_read_metadata_response_message.py +0 -45
  59. h_message_bus/domain/request_messages/vector_save_request_message.py +0 -66
  60. h_message_bus/domain/request_messages/web_get_docs_request_message.py +0 -46
  61. h_message_bus/domain/request_messages/web_search_request_message.py +0 -32
  62. h_message_bus-0.0.39.dist-info/RECORD +0 -76
  63. {h_message_bus-0.0.39.dist-info → h_message_bus-0.0.41.dist-info}/top_level.txt +0 -0
@@ -1,76 +0,0 @@
1
- class TwitterUserMetadata:
2
- def __init__(self,
3
- id: str,
4
- screen_name: str,
5
- user_name: str = None,
6
- description: str = None,
7
- followers_count: int = 0,
8
- like_count: int = 0,
9
- is_verified: bool = False,
10
- url: str = None,
11
- bio_urls: list = None):
12
- """
13
- Initialize a TwitterUserMetadata instance.
14
-
15
- Args:
16
- id (str): The user's Twitter ID
17
- screen_name (str): The user's screen name
18
- user_name (str, optional): The user's name
19
- description (str, optional): The user's bio description
20
- followers_count (int, optional): Number of followers
21
- like_count (int, optional): Number of likes
22
- is_verified (bool, optional): Whether the user is verified
23
- url (str, optional): The user's profile URL
24
- bio_urls (list, optional): URLs mentioned in the user's bio
25
- """
26
- self.id = id
27
- self.screen_name = screen_name
28
- self.user_name = user_name
29
- self.description = description
30
- self.followers_count = followers_count
31
- self.like_count = like_count
32
- self.is_verified = is_verified
33
- self.url = url
34
- self.bio_urls = bio_urls or []
35
-
36
- def to_dict(self) -> dict:
37
- """
38
- Convert TwitterUserMetadata instance to a dictionary.
39
-
40
- Returns:
41
- dict: A dictionary representation of the TwitterUserMetadata instance.
42
- """
43
- return {
44
- 'id': self.id,
45
- 'screen_name': self.screen_name,
46
- 'user_name': self.user_name,
47
- 'description': self.description,
48
- 'followers_count': self.followers_count,
49
- 'like_count': self.like_count,
50
- 'is_verified': self.is_verified,
51
- 'url': self.url,
52
- 'bio_urls': self.bio_urls
53
- }
54
-
55
- @classmethod
56
- def from_dict(cls, data: dict) -> 'TwitterUserMetadata':
57
- """
58
- Create a TwitterUserMetadata instance from a dictionary.
59
-
60
- Args:
61
- data (dict): A dictionary containing TwitterUserMetadata attributes
62
-
63
- Returns:
64
- TwitterUserMetadata: A new TwitterUserMetadata instance
65
- """
66
- return cls(
67
- id=data.get('id'),
68
- screen_name=data.get('screen_name'),
69
- user_name=data.get('user_name'),
70
- description=data.get('description'),
71
- followers_count=data.get('followers_count', 0),
72
- like_count=data.get('like_count', 0),
73
- is_verified=data.get('is_verified', False),
74
- url=data.get('url'),
75
- bio_urls=data.get('bio_urls', [])
76
- )
@@ -1,30 +0,0 @@
1
- from dataclasses import dataclass
2
-
3
-
4
- @dataclass
5
- class VectorCollectionMetadata:
6
- collection_name: str
7
- last_updated: str
8
- last_queried: str
9
- query_count: int = 0
10
-
11
- @classmethod
12
- def from_dict(cls, data: dict) -> 'VectorCollectionMetadata':
13
- """Create an instance from a dictionary."""
14
- return cls(
15
- collection_name=data.get('collection_name', ''),
16
- last_updated=data.get('last_updated', ''),
17
- last_queried=data.get('last_queried', ''),
18
- query_count=data.get('query_count', 0)
19
- )
20
-
21
- def to_dict(self) -> dict:
22
- """Convert instance to a dictionary."""
23
- return {
24
- 'collection_name': self.collection_name,
25
- 'last_updated': self.last_updated,
26
- 'last_queried': self.last_queried,
27
- 'query_count': self.query_count
28
- }
29
-
30
-
@@ -1,22 +0,0 @@
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
- }
File without changes
@@ -1,26 +0,0 @@
1
- from typing import TypeVar, Dict, Any, Type
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 GraphClearRequestMessage(HaiMessage):
9
- """Message to clear all nodes and relationships from 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) -> 'GraphClearRequestMessage':
18
- """Create a message requesting to clear the graph"""
19
- return cls.create(
20
- topic=RequestMessageTopic.GRAPH_CLEAR,
21
- payload={}
22
- )
23
-
24
- @classmethod
25
- def from_hai_message(cls, message: HaiMessage) -> 'GraphClearRequestMessage':
26
- return cls.create_message()
@@ -1,27 +0,0 @@
1
-
2
- from typing import TypeVar, Dict, Any, Type, List
3
-
4
- from ..models.request_message_topic import RequestMessageTopic
5
- from ...domain.models.hai_message import HaiMessage
6
-
7
- T = TypeVar('T', bound='HaiMessage')
8
-
9
- class GraphGetAllRequestMessage(HaiMessage):
10
- """Message to get all nodes and relationships from the graph"""
11
-
12
- @classmethod
13
- def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
14
- """Create a message - inherited from HaiMessage"""
15
- return super().create(topic=topic, payload=payload)
16
-
17
- @classmethod
18
- def create_message(cls) -> 'GraphGetAllRequestMessage':
19
- """Create a message requesting to get all nodes and relationships"""
20
- return cls.create(
21
- topic=RequestMessageTopic.GRAPH_GET_ALL,
22
- payload={}
23
- )
24
-
25
- @classmethod
26
- def from_hai_message(cls, message: HaiMessage) -> 'GraphGetAllRequestMessage':
27
- return cls.create_message()
@@ -1,45 +0,0 @@
1
- from typing import TypeVar, Dict, Any, Type, List
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 GraphGetAllResultResponseMessage(HaiMessage):
9
- """Message containing all nodes and relationships from 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, nodes: List[Dict], relationships: List[Dict]) -> 'GraphGetAllResultResponseMessage':
18
- """Create a message with all nodes and relationships"""
19
- return cls.create(
20
- topic=RequestMessageTopic.GRAPH_GET_ALL_RESPONSE,
21
- payload={
22
- "nodes": nodes,
23
- "relationships": relationships
24
- },
25
- )
26
-
27
- @property
28
- def nodes(self) -> List[Dict]:
29
- """Get the list of nodes from the payload"""
30
- return self.payload.get("nodes", [])
31
-
32
- @property
33
- def relationships(self) -> List[Dict]:
34
- """Get the list of relationships from the payload"""
35
- return self.payload.get("relationships", [])
36
-
37
- @classmethod
38
- def from_hai_message(cls, message: HaiMessage) -> 'GraphGetAllResultResponseMessage':
39
- # Extract the necessary fields from the message payload
40
- payload = message.payload
41
-
42
- return cls.create_message(
43
- nodes=payload.get("nodes", []),
44
- relationships=payload.get("relationships", [])
45
- )
@@ -1,64 +0,0 @@
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
-
9
- class GraphNodeAddRequestMessage(HaiMessage):
10
- """Message to add a node to the graph"""
11
-
12
- @classmethod
13
- def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
14
- """Create a message - inherited from HaiMessage"""
15
- return super().create(topic=topic, payload=payload)
16
-
17
- @classmethod
18
- def create_message(cls, node_id: str, label: str, properties: dict = None,
19
- description: str = None) -> 'GraphNodeAddRequestMessage':
20
- """Create a message requesting to add a node to the graph"""
21
- if properties is None:
22
- properties = {}
23
-
24
- return cls.create(
25
- topic=RequestMessageTopic.GRAPH_NODE_ADD,
26
- payload={
27
- "node_id": node_id,
28
- "label": label,
29
- "properties": properties,
30
- "description": description
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
- @classmethod
55
- def from_hai_message(cls, message: HaiMessage) -> 'GraphNodeAddRequestMessage':
56
- # Extract the necessary fields from the message payload
57
- payload = message.payload
58
-
59
- return cls.create_message(
60
- node_id=payload.get("node_id", ''),
61
- label=payload.get("label", ''),
62
- properties=payload.get("properties", {}),
63
- description=payload.get("description")
64
- )
@@ -1,69 +0,0 @@
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 GraphNodeAddedResponseMessage(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) -> 'GraphNodeAddedResponseMessage':
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_ADD_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) -> 'GraphNodeAddedResponseMessage':
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,39 +0,0 @@
1
-
2
- from typing import TypeVar, Dict, Any, Type
3
-
4
- from ..models.request_message_topic import RequestMessageTopic
5
- from ...domain.models.hai_message import HaiMessage
6
-
7
- T = TypeVar('T', bound='HaiMessage')
8
-
9
- class GraphNodeGetRequestMessage(HaiMessage):
10
- """Message to get a node from the graph by ID"""
11
-
12
- @classmethod
13
- def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
14
- """Create a message - inherited from HaiMessage"""
15
- return super().create(topic=topic, payload=payload)
16
-
17
- @classmethod
18
- def create_message(cls, node_id: str) -> 'GraphNodeGetRequestMessage':
19
- """Create a message requesting to get a node from the graph"""
20
- return cls.create(
21
- topic=RequestMessageTopic.GRAPH_NODE_GET,
22
- payload={
23
- "node_id": node_id
24
- },
25
- )
26
-
27
- @property
28
- def node_id(self) -> str:
29
- """Get the node ID from the payload"""
30
- return self.payload.get("node_id")
31
-
32
- @classmethod
33
- def from_hai_message(cls, message: HaiMessage) -> 'GraphNodeGetRequestMessage':
34
- # Extract the necessary fields from the message payload
35
- payload = message.payload
36
-
37
- return cls.create_message(
38
- node_id=payload.get("node_id", '')
39
- )
@@ -1,70 +0,0 @@
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 GraphNodeGetResultResponseMessage(HaiMessage):
9
- """Message containing a requested node from 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, found: bool = True) -> 'GraphNodeGetResultResponseMessage':
19
- """Create a message with the requested node information"""
20
- if properties is None:
21
- properties = {}
22
-
23
- return cls.create(
24
- topic=RequestMessageTopic.GRAPH_NODE_GET_RESPONSE,
25
- payload={
26
- "node_id": node_id,
27
- "label": label,
28
- "properties": properties,
29
- "description": description,
30
- "found": found
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 found(self) -> bool:
56
- """Check if the node was found"""
57
- return self.payload.get("found", False)
58
-
59
- @classmethod
60
- def from_hai_message(cls, message: HaiMessage) -> 'GraphNodeGetResultResponseMessage':
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
- found=payload.get("found", False)
70
- )
@@ -1,56 +0,0 @@
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 GraphNodeUpdateRequestMessage(HaiMessage):
9
- """Message to update an existing node in 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, properties: dict = None,
18
- description: str = None) -> 'GraphNodeUpdateRequestMessage':
19
- """Create a message requesting to update a node in the graph"""
20
- if properties is None:
21
- properties = {}
22
-
23
- return cls.create(
24
- topic=RequestMessageTopic.GRAPH_NODE_UPDATE,
25
- payload={
26
- "node_id": node_id,
27
- "properties": properties,
28
- "description": description
29
- },
30
- )
31
-
32
- @property
33
- def node_id(self) -> str:
34
- """Get the node ID from the payload"""
35
- return self.payload.get("node_id")
36
-
37
- @property
38
- def properties(self) -> dict:
39
- """Get the properties from the payload"""
40
- return self.payload.get("properties", {})
41
-
42
- @property
43
- def description(self) -> Optional[str]:
44
- """Get the description from the payload"""
45
- return self.payload.get("description")
46
-
47
- @classmethod
48
- def from_hai_message(cls, message: HaiMessage) -> 'GraphNodeUpdateRequestMessage':
49
- # Extract the necessary fields from the message payload
50
- payload = message.payload
51
-
52
- return cls.create_message(
53
- node_id=payload.get("node_id", ''),
54
- properties=payload.get("properties", {}),
55
- description=payload.get("description")
56
- )
@@ -1,69 +0,0 @@
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, success: bool = True) -> '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": success
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,45 +0,0 @@
1
- from typing import TypeVar, Dict, Any, Type
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 GraphNodesByPropertyRequestMessage(HaiMessage):
9
- """Message to get nodes with a specific property value and their relationships"""
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, property_name: str, property_value: any) -> 'GraphNodesByPropertyRequestMessage':
18
- """Create a message requesting nodes with a specific property value"""
19
- return cls.create(
20
- topic=RequestMessageTopic.GRAPH_NODES_BY_PROPERTY,
21
- payload={
22
- "property_name": property_name,
23
- "property_value": property_value
24
- },
25
- )
26
-
27
- @property
28
- def property_name(self) -> str:
29
- """Get the property name from the payload"""
30
- return self.payload.get("property_name")
31
-
32
- @property
33
- def property_value(self) -> any:
34
- """Get the property value from the payload"""
35
- return self.payload.get("property_value")
36
-
37
- @classmethod
38
- def from_hai_message(cls, message: HaiMessage) -> 'GraphNodesByPropertyRequestMessage':
39
- # Extract the necessary fields from the message payload
40
- payload = message.payload
41
-
42
- return cls.create_message(
43
- property_name=payload.get("property_name", ''),
44
- property_value=payload.get("property_value")
45
- )