h-message-bus 0.0.31__tar.gz → 0.0.33__tar.gz

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 (75) hide show
  1. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/PKG-INFO +1 -1
  2. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/pyproject.toml +1 -1
  3. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/request_message_topic.py +18 -0
  4. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/graph_query_operation_request_message.py +114 -0
  5. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/graph_query_operation_response_message.py +85 -0
  6. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_follow_user_request_message.py +40 -0
  7. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_follow_user_response_message.py +43 -0
  8. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_home_timeline_request_message.py +56 -0
  9. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_home_timeline_response_message.py +65 -0
  10. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_post_tweet_request_message.py +40 -0
  11. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_post_tweet_response_message.py +47 -0
  12. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_reply_request_message.py +48 -0
  13. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_reply_response_message.py +54 -0
  14. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_retweet_request_message.py +40 -0
  15. h_message_bus-0.0.33/src/h_message_bus/domain/request_messages/twitter_retweet_response_message.py +43 -0
  16. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus.egg-info/PKG-INFO +1 -1
  17. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus.egg-info/SOURCES.txt +12 -0
  18. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/README.md +0 -0
  19. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/setup.cfg +0 -0
  20. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/__init__.py +0 -0
  21. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/__init__.py +0 -0
  22. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/adapters/__init__.py +0 -0
  23. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/adapters/nats_message_adapter.py +0 -0
  24. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/adapters/nats_publisher_adapter.py +0 -0
  25. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/adapters/nats_subscriber_adapter.py +0 -0
  26. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/application/__init__.py +0 -0
  27. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/application/message_processor.py +0 -0
  28. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/application/message_publisher.py +0 -0
  29. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/application/message_subcriber.py +0 -0
  30. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/__init__.py +0 -0
  31. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/event_messages/__init__.py +0 -0
  32. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/__init__.py +0 -0
  33. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/event_message_topic.py +0 -0
  34. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/hai_message.py +0 -0
  35. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/twitter_message_metadata.py +0 -0
  36. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/twitter_user_metadata.py +0 -0
  37. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/vector_collection_metadata.py +0 -0
  38. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/models/vector_query_answer.py +0 -0
  39. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/__init__.py +0 -0
  40. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_clear_request_message.py +0 -0
  41. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_get_all_request_message.py +0 -0
  42. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_get_all_result_response_message.py +0 -0
  43. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_node_add_request_message.py +0 -0
  44. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_node_added_response_message.py +0 -0
  45. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_node_get_request_message.py +0 -0
  46. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_node_get_result_response_message.py +0 -0
  47. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_node_update_request_message.py +0 -0
  48. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_node_update_response_message.py +0 -0
  49. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_nodes_by_property_request_message.py +0 -0
  50. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_nodes_by_property_response_message.py +0 -0
  51. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_query_request_message.py +0 -0
  52. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/graph_relationship_added_request_message.py +0 -0
  53. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/init_knowledgebase_request.py +0 -0
  54. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/tg_message_request_message.py +0 -0
  55. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/tg_user_message_reply_request_message.py +0 -0
  56. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/tg_user_message_request_message.py +0 -0
  57. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/twitter_get_user_request_message.py +0 -0
  58. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/twitter_get_user_response_message.py +0 -0
  59. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/twitter_get_users_request_message.py +0 -0
  60. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/twitter_get_users_response_message.py +0 -0
  61. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/twitter_user_tweets_request_message.py +0 -0
  62. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/twitter_user_tweets_response_message.py +0 -0
  63. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/vector_query_collection_request_message.py +0 -0
  64. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/vector_query_collection_response_message.py +0 -0
  65. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/vector_read_metadata_request_message.py +0 -0
  66. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/vector_read_metadata_response_message.py +0 -0
  67. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/vector_save_request_message.py +0 -0
  68. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/web_get_docs_request_message.py +0 -0
  69. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/domain/request_messages/web_search_request_message.py +0 -0
  70. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/infrastructure/__init__.py +0 -0
  71. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/infrastructure/nats_client_repository.py +0 -0
  72. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus/infrastructure/nats_config.py +0 -0
  73. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus.egg-info/dependency_links.txt +0 -0
  74. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus.egg-info/requires.txt +0 -0
  75. {h_message_bus-0.0.31 → h_message_bus-0.0.33}/src/h_message_bus.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_message_bus
3
- Version: 0.0.31
3
+ Version: 0.0.33
4
4
  Summary: Message bus integration for HAI
5
5
  Author-email: shoebill <shoebill.hai@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@
4
4
 
5
5
  [project]
6
6
  name = "h_message_bus"
7
- version = "0.0.31"
7
+ version = "0.0.33"
8
8
  authors = [
9
9
  {name = "shoebill", email = "shoebill.hai@gmail.com"},
10
10
  ]
@@ -38,6 +38,21 @@ class RequestMessageTopic(str, Enum):
38
38
  TWITTER_USER_SEND_AI_CHAT_SEND = "hai.twitter.user.chat.send"
39
39
  TWITTER_USER_SEND_AI_CHAT_SEND_RESPONSE = "hai.twitter.user.chat.send.response"
40
40
 
41
+ TWITTER_FOLLOW_USER= "hai.twitter.follow.user"
42
+ TWITTER_FOLLOW_USER_RESPONSE = "hai.twitter.follow.user.response"
43
+
44
+ TWITTER_GET_HOME_TIMELINE= "hai.twitter.get.home.timeline"
45
+ TWITTER_GET_HOME_TIMELINE_RESPONSE = "hai.twitter.get.home.timeline.response"
46
+
47
+ TWITTER_RETWEET= "hai.twitter.retweet"
48
+ TWITTER_RETWEET_RESPONSE = "hai.twitter.retweet.response"
49
+
50
+ TWITTER_REPLY= "hai.twitter.reply"
51
+ TWITTER_REPLY_RESPONSE = "hai.twitter.reply.response"
52
+
53
+ TWITTER_POST_TWEET= "hai.twitter.post.tweet"
54
+ TWITTER_POST_TWEET_RESPONSE = "hai.twitter.post.tweet.response"
55
+
41
56
  # tools
42
57
  WEB_SEARCH = "hai.tools.web.search"
43
58
  WEB_SEARCH_RESPONSE = "hai.tools.web.search.response"
@@ -63,6 +78,9 @@ class RequestMessageTopic(str, Enum):
63
78
  GRAPH_GET_ALL = "hai.graph.get.all"
64
79
  GRAPH_NODES_BY_PROPERTY = "hai.graph.nodes.by.property"
65
80
 
81
+ GRAPH_QUERY_OPERATION = "hai.graph.query.operation"
82
+ GRAPH_QUERY_OPERATION_RESPONSE = "hai.graph.query.operation.response"
83
+
66
84
  GRAPH_NODE_ADD_RESPONSE = "hai.graph.node.add.response"
67
85
  GRAPH_NODE_UPDATE_RESPONSE = "hai.graph.node.update.response"
68
86
  GRAPH_NODE_GET_RESPONSE = "hai.graph.node.get.response"
@@ -0,0 +1,114 @@
1
+ import json
2
+ from typing import Dict, Any, Type, TypeVar
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
+
10
+ class GraphQueryOperationRequestMessage(HaiMessage):
11
+ """Message to request graph query operations"""
12
+
13
+ @classmethod
14
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
15
+ """Create a message - inherited from HaiMessage"""
16
+ return super().create(topic=topic, payload=payload)
17
+
18
+ @classmethod
19
+ def create_message(cls,
20
+ operation_type: str,
21
+ anchor_node: str,
22
+ relationship_direction: str = None,
23
+ relationship_type: str = None,
24
+ limit: int = None,
25
+ traversal_depth: int = None) -> 'GraphQueryOperationRequestMessage':
26
+ """
27
+ Create a message requesting a graph query operation
28
+
29
+ Args:
30
+ operation_type: One of 'FIND_RELATED_NODES', 'GET_NODE_INFO', 'COUNT_RELATIONSHIPS'
31
+ anchor_node: The central node in the query (e.g., 'hyperliquid')
32
+ relationship_direction: One of 'INCOMING', 'OUTGOING', or 'BOTH'
33
+ relationship_type: The relationship type to traverse (e.g., 'BUILDS_ON')
34
+ limit: Numerical limit of results to return
35
+ traversal_depth: How many relationship hops to traverse
36
+
37
+ Returns:
38
+ A new GraphQueryOperationRequestMessage
39
+ """
40
+ # Build the query operation dictionary
41
+ query_operation = {
42
+ "operation_type": operation_type,
43
+ "anchor_node": anchor_node,
44
+ }
45
+
46
+ # Add optional parameters if provided
47
+ if relationship_direction is not None:
48
+ query_operation["relationship_direction"] = relationship_direction
49
+
50
+ if relationship_type is not None:
51
+ query_operation["relationship_type"] = relationship_type
52
+
53
+ if limit is not None:
54
+ query_operation["limit"] = f"{limit}"
55
+
56
+ if traversal_depth is not None:
57
+ query_operation["traversal_depth"] = f"{traversal_depth}"
58
+
59
+ return cls.create(
60
+ topic=RequestMessageTopic.GRAPH_QUERY_OPERATION,
61
+ payload={"query_operation": json.dumps(query_operation)},
62
+ )
63
+
64
+ @property
65
+ def query_operation(self) -> Dict[str, Any]:
66
+ """Get the query operation from the payload"""
67
+ query_operation_payload = self.payload.get("query_operation", "{}")
68
+ return json.loads(query_operation_payload)
69
+
70
+ @property
71
+ def operation_type(self) -> str:
72
+ """Get the operation type from the query operation"""
73
+ return self.query_operation.get("operation_type", "")
74
+
75
+ @property
76
+ def anchor_node(self) -> str:
77
+ """Get the anchor node from the query operation"""
78
+ return self.query_operation.get("anchor_node", "")
79
+
80
+ @property
81
+ def relationship_direction(self) -> str:
82
+ """Get the relationship direction from the query operation"""
83
+ return self.query_operation.get("relationship_direction", "BOTH")
84
+
85
+ @property
86
+ def relationship_type(self) -> str:
87
+ """Get the relationship type from the query operation"""
88
+ return self.query_operation.get("relationship_type", "")
89
+
90
+ @property
91
+ def limit(self) -> int:
92
+ """Get the limit from the query operation"""
93
+ return int(self.query_operation.get("limit", 10))
94
+
95
+ @property
96
+ def traversal_depth(self) -> int:
97
+ """Get the traversal depth from the query operation"""
98
+ return int(self.query_operation.get("traversal_depth", 1))
99
+
100
+ @classmethod
101
+ def from_hai_message(cls, message: HaiMessage) -> 'GraphQueryOperationRequestMessage':
102
+ """Create a GraphQueryOperationRequestMessage from a HaiMessage"""
103
+ payload = message.payload
104
+ query_operation_str = payload.get("query_operation", "{}")
105
+ query_operation = json.loads(query_operation_str)
106
+
107
+ return cls.create_message(
108
+ operation_type=query_operation.get("operation_type", ""),
109
+ anchor_node=query_operation.get("anchor_node", ""),
110
+ relationship_direction=query_operation.get("relationship_direction"),
111
+ relationship_type=query_operation.get("relationship_type"),
112
+ limit=query_operation.get("limit"),
113
+ traversal_depth=query_operation.get("traversal_depth")
114
+ )
@@ -0,0 +1,85 @@
1
+ import json
2
+ from typing import Dict, Any, TypeVar, Type
3
+
4
+ from ...domain.models.hai_message import HaiMessage
5
+ from ..models.request_message_topic import RequestMessageTopic
6
+
7
+ T = TypeVar('T', bound='HaiMessage')
8
+
9
+ class GraphQueryOperationResponseMessage(HaiMessage):
10
+ """Message with results from graph query operations"""
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,
19
+ operation_type: str,
20
+ result: Dict[str, Any],
21
+ success: bool = True,
22
+ error_message: str = None) -> 'GraphQueryOperationResponseMessage':
23
+ """
24
+ Create a response message with graph query operation results
25
+
26
+ Args:
27
+ operation_type: The type of operation that was performed
28
+ result: Dictionary containing the operation results
29
+ success: Whether the operation was successful
30
+ error_message: Error message if the operation failed
31
+
32
+ Returns:
33
+ A new GraphQueryOperationResponseMessage
34
+ """
35
+ payload = {
36
+ "operation_type": operation_type,
37
+ "result": json.dumps(result),
38
+ "success": success
39
+ }
40
+
41
+ if error_message:
42
+ payload["error_message"] = error_message
43
+
44
+ return cls.create(
45
+ topic=RequestMessageTopic.GRAPH_QUERY_OPERATION_RESPONSE,
46
+ payload=payload,
47
+ )
48
+
49
+ @property
50
+ def operation_type(self) -> str:
51
+ """Get the operation type from the payload"""
52
+ return self.payload.get("operation_type", "")
53
+
54
+ @property
55
+ def result(self) -> Dict[str, Any]:
56
+ """Get the result from the payload"""
57
+ result_str = self.payload.get("result", "{}")
58
+ return json.loads(result_str)
59
+
60
+ @property
61
+ def success(self) -> bool:
62
+ """Get the success status from the payload"""
63
+ return self.payload.get("success", False)
64
+
65
+ @property
66
+ def error_message(self) -> str:
67
+ """Get the error message from the payload"""
68
+ return self.payload.get("error_message", "")
69
+
70
+ @classmethod
71
+ def from_hai_message(cls, message: HaiMessage) -> 'GraphQueryOperationResponseMessage':
72
+ """Create a GraphQueryOperationResponseMessage from a HaiMessage"""
73
+ payload = message.payload
74
+ operation_type = payload.get("operation_type", "")
75
+ result_str = payload.get("result", "{}")
76
+ result = json.loads(result_str)
77
+ success = payload.get("success", False)
78
+ error_message = payload.get("error_message")
79
+
80
+ return cls.create_message(
81
+ operation_type=operation_type,
82
+ result=result,
83
+ success=success,
84
+ error_message=error_message
85
+ )
@@ -0,0 +1,40 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterFollowUserRequestMessage')
8
+
9
+ @dataclass
10
+ class TwitterFollowUserRequestMessage(HaiMessage):
11
+ """Message to request following a Twitter user"""
12
+
13
+ @classmethod
14
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
15
+ """Create a message - inherited from HaiMessage"""
16
+ return super().create(topic=topic, payload=payload)
17
+
18
+ @classmethod
19
+ def create_message(cls, user_id: str) -> 'TwitterFollowUserRequestMessage':
20
+ """Create a message requesting to follow a Twitter user"""
21
+ return cls.create(
22
+ topic=RequestMessageTopic.TWITTER_FOLLOW_USER, # You'll need to add this to RequestMessageTopic
23
+ payload={
24
+ "user_id": user_id
25
+ },
26
+ )
27
+
28
+ @property
29
+ def user_id(self) -> str:
30
+ """Get the user ID from the payload"""
31
+ return self.payload.get("user_id", "")
32
+
33
+ @classmethod
34
+ def from_hai_message(cls, message: HaiMessage) -> 'TwitterFollowUserRequestMessage':
35
+ """Create a TwitterFollowUserRequestMessage from a HaiMessage"""
36
+ payload = message.payload
37
+
38
+ return cls.create_message(
39
+ user_id=payload.get("user_id", "")
40
+ )
@@ -0,0 +1,43 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterFollowUserResponseMessage')
8
+
9
+ @dataclass
10
+ class TwitterFollowUserResponseMessage(HaiMessage):
11
+ """Message to respond to a request to follow a Twitter user"""
12
+
13
+ @classmethod
14
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
15
+ """Create a message - inherited from HaiMessage"""
16
+ return super().create(topic=topic, payload=payload)
17
+
18
+ @classmethod
19
+ def create_message(cls, user_id: str, success: bool, error_message: str = "") -> 'TwitterFollowUserResponseMessage':
20
+ """Create a response message for a request to follow a Twitter user"""
21
+ return cls.create(
22
+ topic=RequestMessageTopic.TWITTER_FOLLOW_USER_RESPONSE, # You'll need to add this to ResponseMessageTopic
23
+ payload={
24
+ "user_id": user_id,
25
+ "success": success,
26
+ "error_message": error_message
27
+ },
28
+ )
29
+
30
+ @property
31
+ def user_id(self) -> str:
32
+ """Get the user ID from the payload"""
33
+ return self.payload.get("user_id", "")
34
+
35
+ @property
36
+ def success(self) -> bool:
37
+ """Get whether the follow operation was successful"""
38
+ return self.payload.get("success", False)
39
+
40
+ @property
41
+ def error_message(self) -> str:
42
+ """Get the error message if the follow operation failed"""
43
+ return self.payload.get("error_message", "")
@@ -0,0 +1,56 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterHomeTimelineRequestMessage')
8
+
9
+ @dataclass
10
+ class TwitterHomeTimelineRequestMessage(HaiMessage):
11
+ """Message to request the home timeline for the authenticated Twitter user"""
12
+
13
+ @classmethod
14
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
15
+ """Create a message - inherited from HaiMessage"""
16
+ return super().create(topic=topic, payload=payload)
17
+
18
+ @classmethod
19
+ def create_message(cls, max_results: int = 100,
20
+ include_replies: bool = True,
21
+ include_retweets: bool = True) -> 'TwitterHomeTimelineRequestMessage':
22
+ """Create a message requesting the Twitter home timeline"""
23
+ return cls.create(
24
+ topic=RequestMessageTopic.TWITTER_GET_HOME_TIMELINE, # You'll need to add this to RequestMessageTopic
25
+ payload={
26
+ "max_results": max_results,
27
+ "include_replies": include_replies,
28
+ "include_retweets": include_retweets
29
+ },
30
+ )
31
+
32
+ @property
33
+ def max_results(self) -> int:
34
+ """Get the maximum number of results from the payload"""
35
+ return self.payload.get("max_results", 100)
36
+
37
+ @property
38
+ def include_replies(self) -> bool:
39
+ """Get whether to include replies from the payload"""
40
+ return self.payload.get("include_replies", True)
41
+
42
+ @property
43
+ def include_retweets(self) -> bool:
44
+ """Get whether to include retweets from the payload"""
45
+ return self.payload.get("include_retweets", True)
46
+
47
+ @classmethod
48
+ def from_hai_message(cls, message: HaiMessage) -> 'TwitterHomeTimelineRequestMessage':
49
+ """Create a TwitterHomeTimelineRequestMessage from a HaiMessage"""
50
+ payload = message.payload
51
+
52
+ return cls.create_message(
53
+ max_results=payload.get("max_results", 100),
54
+ include_replies=payload.get("include_replies", True),
55
+ include_retweets=payload.get("include_retweets", True)
56
+ )
@@ -0,0 +1,65 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar, List
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterHomeTimelineResponseMessage')
8
+
9
+
10
+ @dataclass
11
+ class TwitterMessageMetaData:
12
+ """Metadata about a Twitter message"""
13
+ tweet_id: str
14
+ user: Dict[str, Any]
15
+ message: str
16
+ created_at: str
17
+ view_count: int
18
+ retweet_count: int
19
+ reply_count: int
20
+
21
+
22
+ @dataclass
23
+ class TwitterHomeTimelineResponseMessage(HaiMessage):
24
+ """Message containing the home timeline for the authenticated Twitter user"""
25
+
26
+ @classmethod
27
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
28
+ """Create a message - inherited from HaiMessage"""
29
+ return super().create(topic=topic, payload=payload)
30
+
31
+ @classmethod
32
+ def create_message(cls, tweets: List[Dict[str, Any]]) -> 'TwitterHomeTimelineResponseMessage':
33
+ """Create a response message with the user's home timeline tweets"""
34
+ return cls.create(
35
+ topic=RequestMessageTopic.TWITTER_GET_HOME_TIMELINE_RESPONSE,
36
+ # You'll need to add this to ResponseMessageTopic
37
+ payload={
38
+ "tweets": tweets
39
+ },
40
+ )
41
+
42
+ @property
43
+ def tweets(self) -> List[Dict[str, Any]]:
44
+ """Get the tweets from the payload"""
45
+ return self.payload.get("tweets", [])
46
+
47
+ @classmethod
48
+ def from_twitter_messages(cls,
49
+ twitter_messages: List[TwitterMessageMetaData]) -> 'TwitterHomeTimelineResponseMessage':
50
+ """Create a TwitterHomeTimelineResponseMessage from a list of TwitterMessageMetaData"""
51
+ tweet_list = []
52
+
53
+ for message in twitter_messages:
54
+ tweet_data = {
55
+ "tweet_id": message.tweet_id,
56
+ "message": message.message,
57
+ "created_at": message.created_at,
58
+ "view_count": message.view_count,
59
+ "retweet_count": message.retweet_count,
60
+ "reply_count": message.reply_count,
61
+ "user": message.user
62
+ }
63
+ tweet_list.append(tweet_data)
64
+
65
+ return cls.create_message(tweets=tweet_list)
@@ -0,0 +1,40 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterPostTweetRequestMessage')
8
+
9
+ @dataclass
10
+ class TwitterPostTweetRequestMessage(HaiMessage):
11
+ """Message to request posting a new tweet"""
12
+
13
+ @classmethod
14
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
15
+ """Create a message - inherited from HaiMessage"""
16
+ return super().create(topic=topic, payload=payload)
17
+
18
+ @classmethod
19
+ def create_message(cls, text: str) -> 'TwitterPostTweetRequestMessage':
20
+ """Create a message requesting to post a new tweet"""
21
+ return cls.create(
22
+ topic=RequestMessageTopic.TWITTER_POST_TWEET, # You'll need to add this to RequestMessageTopic
23
+ payload={
24
+ "text": text
25
+ },
26
+ )
27
+
28
+ @property
29
+ def text(self) -> str:
30
+ """Get the text content of the tweet from the payload"""
31
+ return self.payload.get("text", "")
32
+
33
+ @classmethod
34
+ def from_hai_message(cls, message: HaiMessage) -> 'TwitterPostTweetRequestMessage':
35
+ """Create a TwitterPostTweetRequestMessage from a HaiMessage"""
36
+ payload = message.payload
37
+
38
+ return cls.create_message(
39
+ text=payload.get("text", "")
40
+ )
@@ -0,0 +1,47 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar, Optional
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterPostTweetResponseMessage')
8
+
9
+
10
+ @dataclass
11
+ class TwitterPostTweetResponseMessage(HaiMessage):
12
+ """Message to respond to a request to post a new tweet"""
13
+
14
+ @classmethod
15
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
16
+ """Create a message - inherited from HaiMessage"""
17
+ return super().create(topic=topic, payload=payload)
18
+
19
+ @classmethod
20
+ def create_message(cls,
21
+ success: bool,
22
+ tweet: Optional[Dict[str, Any]] = None,
23
+ error_message: str = "") -> 'TwitterPostTweetResponseMessage':
24
+ """Create a response message for a request to post a new tweet"""
25
+ return cls.create(
26
+ topic=RequestMessageTopic.TWITTER_POST_TWEET_RESPONSE, # You'll need to add this to ResponseMessageTopic
27
+ payload={
28
+ "success": success,
29
+ "tweet": tweet,
30
+ "error_message": error_message
31
+ },
32
+ )
33
+
34
+ @property
35
+ def success(self) -> bool:
36
+ """Get whether the post tweet operation was successful"""
37
+ return self.payload.get("success", False)
38
+
39
+ @property
40
+ def tweet(self) -> Optional[Dict[str, Any]]:
41
+ """Get the posted tweet data if the operation was successful"""
42
+ return self.payload.get("tweet", None)
43
+
44
+ @property
45
+ def error_message(self) -> str:
46
+ """Get the error message if the post tweet operation failed"""
47
+ return self.payload.get("error_message", "")
@@ -0,0 +1,48 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterReplyRequestMessage')
8
+
9
+
10
+ @dataclass
11
+ class TwitterReplyRequestMessage(HaiMessage):
12
+ """Message to request replying to a tweet"""
13
+
14
+ @classmethod
15
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
16
+ """Create a message - inherited from HaiMessage"""
17
+ return super().create(topic=topic, payload=payload)
18
+
19
+ @classmethod
20
+ def create_message(cls, tweet_id: str, text: str) -> 'TwitterReplyRequestMessage':
21
+ """Create a message requesting to reply to a tweet"""
22
+ return cls.create(
23
+ topic=RequestMessageTopic.TWITTER_REPLY, # You'll need to add this to RequestMessageTopic
24
+ payload={
25
+ "tweet_id": tweet_id,
26
+ "text": text
27
+ },
28
+ )
29
+
30
+ @property
31
+ def tweet_id(self) -> str:
32
+ """Get the tweet ID to reply to from the payload"""
33
+ return self.payload.get("tweet_id", "")
34
+
35
+ @property
36
+ def text(self) -> str:
37
+ """Get the text content of the reply from the payload"""
38
+ return self.payload.get("text", "")
39
+
40
+ @classmethod
41
+ def from_hai_message(cls, message: HaiMessage) -> 'TwitterReplyRequestMessage':
42
+ """Create a TwitterReplyRequestMessage from a HaiMessage"""
43
+ payload = message.payload
44
+
45
+ return cls.create_message(
46
+ tweet_id=payload.get("tweet_id", ""),
47
+ text=payload.get("text", "")
48
+ )
@@ -0,0 +1,54 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar, Optional
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterReplyResponseMessage')
8
+
9
+
10
+ @dataclass
11
+ class TwitterReplyResponseMessage(HaiMessage):
12
+ """Message to respond to a request to reply to a tweet"""
13
+
14
+ @classmethod
15
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
16
+ """Create a message - inherited from HaiMessage"""
17
+ return super().create(topic=topic, payload=payload)
18
+
19
+ @classmethod
20
+ def create_message(cls,
21
+ original_tweet_id: str,
22
+ success: bool,
23
+ reply_tweet: Optional[Dict[str, Any]] = None,
24
+ error_message: str = "") -> 'TwitterReplyResponseMessage':
25
+ """Create a response message for a request to reply to a tweet"""
26
+ return cls.create(
27
+ topic=RequestMessageTopic.TWITTER_REPLY_RESPONSE, # You'll need to add this to ResponseMessageTopic
28
+ payload={
29
+ "original_tweet_id": original_tweet_id,
30
+ "success": success,
31
+ "reply_tweet": reply_tweet,
32
+ "error_message": error_message
33
+ },
34
+ )
35
+
36
+ @property
37
+ def original_tweet_id(self) -> str:
38
+ """Get the original tweet ID that was replied to"""
39
+ return self.payload.get("original_tweet_id", "")
40
+
41
+ @property
42
+ def success(self) -> bool:
43
+ """Get whether the reply operation was successful"""
44
+ return self.payload.get("success", False)
45
+
46
+ @property
47
+ def reply_tweet(self) -> Optional[Dict[str, Any]]:
48
+ """Get the reply tweet data if the operation was successful"""
49
+ return self.payload.get("reply_tweet", None)
50
+
51
+ @property
52
+ def error_message(self) -> str:
53
+ """Get the error message if the reply operation failed"""
54
+ return self.payload.get("error_message", "")
@@ -0,0 +1,40 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterRetweetRequestMessage')
8
+
9
+ @dataclass
10
+ class TwitterRetweetRequestMessage(HaiMessage):
11
+ """Message to request retweeting a tweet"""
12
+
13
+ @classmethod
14
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
15
+ """Create a message - inherited from HaiMessage"""
16
+ return super().create(topic=topic, payload=payload)
17
+
18
+ @classmethod
19
+ def create_message(cls, tweet_id: str) -> 'TwitterRetweetRequestMessage':
20
+ """Create a message requesting to retweet a tweet"""
21
+ return cls.create(
22
+ topic=RequestMessageTopic.TWITTER_RETWEET, # You'll need to add this to RequestMessageTopic
23
+ payload={
24
+ "tweet_id": tweet_id
25
+ },
26
+ )
27
+
28
+ @property
29
+ def tweet_id(self) -> str:
30
+ """Get the tweet ID from the payload"""
31
+ return self.payload.get("tweet_id", "")
32
+
33
+ @classmethod
34
+ def from_hai_message(cls, message: HaiMessage) -> 'TwitterRetweetRequestMessage':
35
+ """Create a TwitterRetweetRequestMessage from a HaiMessage"""
36
+ payload = message.payload
37
+
38
+ return cls.create_message(
39
+ tweet_id=payload.get("tweet_id", "")
40
+ )
@@ -0,0 +1,43 @@
1
+ from dataclasses import dataclass
2
+ from typing import Type, Dict, Any, TypeVar
3
+
4
+ from ..models.request_message_topic import RequestMessageTopic
5
+ from ...domain.models.hai_message import HaiMessage
6
+
7
+ T = TypeVar('T', bound='TwitterRetweetResponseMessage')
8
+
9
+ @dataclass
10
+ class TwitterRetweetResponseMessage(HaiMessage):
11
+ """Message to respond to a request to retweet a tweet"""
12
+
13
+ @classmethod
14
+ def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
15
+ """Create a message - inherited from HaiMessage"""
16
+ return super().create(topic=topic, payload=payload)
17
+
18
+ @classmethod
19
+ def create_message(cls, tweet_id: str, success: bool, error_message: str = "") -> 'TwitterRetweetResponseMessage':
20
+ """Create a response message for a request to retweet a tweet"""
21
+ return cls.create(
22
+ topic=RequestMessageTopic.TWITTER_RETWEET_RESPONSE, # You'll need to add this to ResponseMessageTopic
23
+ payload={
24
+ "tweet_id": tweet_id,
25
+ "success": success,
26
+ "error_message": error_message
27
+ },
28
+ )
29
+
30
+ @property
31
+ def tweet_id(self) -> str:
32
+ """Get the tweet ID from the payload"""
33
+ return self.payload.get("tweet_id", "")
34
+
35
+ @property
36
+ def success(self) -> bool:
37
+ """Get whether the retweet operation was successful"""
38
+ return self.payload.get("success", False)
39
+
40
+ @property
41
+ def error_message(self) -> str:
42
+ """Get the error message if the retweet operation failed"""
43
+ return self.payload.get("error_message", "")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_message_bus
3
- Version: 0.0.31
3
+ Version: 0.0.33
4
4
  Summary: Message bus integration for HAI
5
5
  Author-email: shoebill <shoebill.hai@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -37,16 +37,28 @@ src/h_message_bus/domain/request_messages/graph_node_update_request_message.py
37
37
  src/h_message_bus/domain/request_messages/graph_node_update_response_message.py
38
38
  src/h_message_bus/domain/request_messages/graph_nodes_by_property_request_message.py
39
39
  src/h_message_bus/domain/request_messages/graph_nodes_by_property_response_message.py
40
+ src/h_message_bus/domain/request_messages/graph_query_operation_request_message.py
41
+ src/h_message_bus/domain/request_messages/graph_query_operation_response_message.py
40
42
  src/h_message_bus/domain/request_messages/graph_query_request_message.py
41
43
  src/h_message_bus/domain/request_messages/graph_relationship_added_request_message.py
42
44
  src/h_message_bus/domain/request_messages/init_knowledgebase_request.py
43
45
  src/h_message_bus/domain/request_messages/tg_message_request_message.py
44
46
  src/h_message_bus/domain/request_messages/tg_user_message_reply_request_message.py
45
47
  src/h_message_bus/domain/request_messages/tg_user_message_request_message.py
48
+ src/h_message_bus/domain/request_messages/twitter_follow_user_request_message.py
49
+ src/h_message_bus/domain/request_messages/twitter_follow_user_response_message.py
46
50
  src/h_message_bus/domain/request_messages/twitter_get_user_request_message.py
47
51
  src/h_message_bus/domain/request_messages/twitter_get_user_response_message.py
48
52
  src/h_message_bus/domain/request_messages/twitter_get_users_request_message.py
49
53
  src/h_message_bus/domain/request_messages/twitter_get_users_response_message.py
54
+ src/h_message_bus/domain/request_messages/twitter_home_timeline_request_message.py
55
+ src/h_message_bus/domain/request_messages/twitter_home_timeline_response_message.py
56
+ src/h_message_bus/domain/request_messages/twitter_post_tweet_request_message.py
57
+ src/h_message_bus/domain/request_messages/twitter_post_tweet_response_message.py
58
+ src/h_message_bus/domain/request_messages/twitter_reply_request_message.py
59
+ src/h_message_bus/domain/request_messages/twitter_reply_response_message.py
60
+ src/h_message_bus/domain/request_messages/twitter_retweet_request_message.py
61
+ src/h_message_bus/domain/request_messages/twitter_retweet_response_message.py
50
62
  src/h_message_bus/domain/request_messages/twitter_user_tweets_request_message.py
51
63
  src/h_message_bus/domain/request_messages/twitter_user_tweets_response_message.py
52
64
  src/h_message_bus/domain/request_messages/vector_query_collection_request_message.py
File without changes
File without changes