h-message-bus 0.0.40__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 +2 -2
  2. h_message_bus/infrastructure/nats_config.py +1 -1
  3. {h_message_bus-0.0.40.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.40.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.40.dist-info/RECORD +0 -76
  63. {h_message_bus-0.0.40.dist-info → h_message_bus-0.0.41.dist-info}/top_level.txt +0 -0
@@ -1,114 +0,0 @@
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
- )
@@ -1,85 +0,0 @@
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
- )
@@ -1,48 +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 GraphQueryRequestMessage(HaiMessage):
9
- """Message to perform a custom query on 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, query: str, parameters: dict = None) -> 'GraphQueryRequestMessage':
18
- """Create a message requesting to perform a custom query on the graph"""
19
- if parameters is None:
20
- parameters = {}
21
-
22
- return cls.create(
23
- topic=RequestMessageTopic.GRAPH_QUERY,
24
- payload={
25
- "query": query,
26
- "parameters": parameters
27
- },
28
- )
29
-
30
- @property
31
- def query(self) -> str:
32
- """Get the query from the payload"""
33
- return self.payload.get("query")
34
-
35
- @property
36
- def parameters(self) -> dict:
37
- """Get the query parameters from the payload"""
38
- return self.payload.get("parameters", {})
39
-
40
- @classmethod
41
- def from_hai_message(cls, message: HaiMessage) -> 'GraphQueryRequestMessage':
42
- # Extract the necessary fields from the message payload
43
- payload = message.payload
44
-
45
- return cls.create_message(
46
- query=payload.get("query", ''),
47
- parameters=payload.get("parameters", {})
48
- )
@@ -1,63 +0,0 @@
1
- from typing import TypeVar, Dict, Any, Type
2
-
3
- from ...domain.models.hai_message import HaiMessage
4
- from ..models.request_message_topic import RequestMessageTopic
5
-
6
- T = TypeVar('T', bound='HaiMessage')
7
-
8
- class GraphRelationshipAddRequestMessage(HaiMessage):
9
- """Message to add a relationship between nodes 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, source_node_id: str, target_node_id: str,
18
- relationship_type: str, properties: dict = None) -> 'GraphRelationshipAddRequestMessage':
19
- """Create a message requesting to add a relationship to the graph"""
20
- if properties is None:
21
- properties = {}
22
-
23
- return cls.create(
24
- topic=RequestMessageTopic.GRAPH_RELATIONSHIP_ADD,
25
- payload={
26
- "source_node_id": source_node_id,
27
- "target_node_id": target_node_id,
28
- "relationship_type": relationship_type,
29
- "properties": properties
30
- },
31
- )
32
-
33
- @property
34
- def source_node_id(self) -> str:
35
- """Get the source node ID from the payload"""
36
- return self.payload.get("source_node_id")
37
-
38
- @property
39
- def target_node_id(self) -> str:
40
- """Get the target node ID from the payload"""
41
- return self.payload.get("target_node_id")
42
-
43
- @property
44
- def relationship_type(self) -> str:
45
- """Get the relationship type from the payload"""
46
- return self.payload.get("relationship_type")
47
-
48
- @property
49
- def properties(self) -> dict:
50
- """Get the properties from the payload"""
51
- return self.payload.get("properties", {})
52
-
53
- @classmethod
54
- def from_hai_message(cls, message: HaiMessage) -> 'GraphRelationshipAddRequestMessage':
55
- # Extract the necessary fields from the message payload
56
- payload = message.payload
57
-
58
- return cls.create_message(
59
- source_node_id=payload.get("source_node_id", ''),
60
- target_node_id=payload.get("target_node_id", ''),
61
- relationship_type=payload.get("relationship_type", ''),
62
- properties=payload.get("properties", {})
63
- )
@@ -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 InitKnowledgeBaseRequestMessage(HaiMessage):
9
-
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) -> 'InitKnowledgeBaseRequestMessage':
18
- """Create a message requesting to clear the graph"""
19
- return cls.create(
20
- topic=RequestMessageTopic.INIT_KNOWLEDGE_BASE,
21
- payload={}
22
- )
23
-
24
- @classmethod
25
- def from_hai_message(cls, message: HaiMessage) -> 'InitKnowledgeBaseRequestMessage':
26
- return cls.create_message()
@@ -1,48 +0,0 @@
1
- from typing import Type, TypeVar, Dict, Any
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 TelegramMessageRequestMessage(HaiMessage):
10
- """Message containing user message data"""
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, message: str, chat_id: int) -> 'TelegramMessageRequestMessage':
19
-
20
- payload = {
21
- "message": message,
22
- "chat_id": chat_id,
23
- }
24
-
25
- return cls.create(
26
- topic=RequestMessageTopic.TG_CHAT_SEND,
27
- payload=payload
28
- )
29
-
30
- @property
31
- def message(self) -> str:
32
- """Get the message content from the payload"""
33
- return self.payload.get("message", "")
34
-
35
- @property
36
- def chat_id(self) -> int:
37
- """Get the Telegram chat ID from the payload"""
38
- return self.payload.get("chat_id", 0)
39
-
40
- @classmethod
41
- def from_hai_message(cls, message: HaiMessage) -> 'TelegramMessageRequestMessage':
42
- payload = message.payload
43
-
44
- return cls.create_message(
45
- message=payload.get("message", ""),
46
- chat_id=payload.get("chat_id")
47
- )
48
-
@@ -1,56 +0,0 @@
1
- from typing import Type, TypeVar, Dict, Any
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 TelegramUserMessageReplyRequestMessage(HaiMessage):
10
- """Message containing user message data"""
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, message: str, chat_id: int,
19
- message_id: int) -> 'TelegramUserMessageReplyRequestMessage':
20
-
21
- payload = {
22
- "message": message,
23
- "chat_id": chat_id,
24
- "message_id": message_id,
25
- }
26
-
27
- return cls.create(
28
- topic=RequestMessageTopic.TG_CHAT_REPLY,
29
- payload=payload
30
- )
31
-
32
- @property
33
- def message(self) -> str:
34
- """Get the message content from the payload"""
35
- return self.payload.get("message", "")
36
-
37
- @property
38
- def chat_id(self) -> int:
39
- """Get the Telegram chat ID from the payload"""
40
- return self.payload.get("chat_id", 0)
41
-
42
- @property
43
- def message_id(self) -> int:
44
- """Get the Telegram message ID from the payload"""
45
- return self.payload.get("message_id", 0)
46
-
47
- @classmethod
48
- def from_hai_message(cls, message: HaiMessage) -> 'TelegramUserMessageReplyRequestMessage':
49
- payload = message.payload
50
-
51
- return cls.create_message(
52
- message=payload.get("message", ""),
53
- chat_id=payload.get("chat_id"),
54
- message_id=payload.get("message_id")
55
- )
56
-
@@ -1,93 +0,0 @@
1
- from typing import Type, TypeVar, Dict, Any, 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 TelegramUserMessageRequestMessage(HaiMessage):
10
- """Message containing user message data"""
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, message: str, user_id: str, username: str,
19
- chat_id: str,
20
- message_id: str,
21
- replied_to_text: Optional[str] = None) -> 'TelegramUserMessageRequestMessage':
22
- """Create a message with user message data
23
-
24
- Args:
25
- message: The cleaned message content
26
- user_id: The ID of the user
27
- username: The username of the user
28
- replied_to_text: The text being replied to, if any
29
- chat_id: The Telegram chat ID
30
- message_id: The Telegram message ID
31
-
32
- Returns:
33
- A new TelegramUserMessageRequestMessage instance
34
- """
35
- payload = {
36
- "message": message,
37
- "user_id": user_id,
38
- "username": username,
39
- "chat_id" : chat_id,
40
- "message_id" : message_id
41
- }
42
-
43
- if replied_to_text:
44
- payload["replied_to_text"] = replied_to_text
45
-
46
- return cls.create(
47
- topic=RequestMessageTopic.TG_USER_CHAT_SEND,
48
- payload=payload
49
- )
50
-
51
- @property
52
- def message(self) -> str:
53
- """Get the message content from the payload"""
54
- return self.payload.get("message", "")
55
-
56
- @property
57
- def user_id(self) -> str:
58
- """Get the user ID from the payload"""
59
- return self.payload.get("user_id", "")
60
-
61
- @property
62
- def username(self) -> str:
63
- """Get the username from the payload"""
64
- return self.payload.get("username", "")
65
-
66
- @property
67
- def replied_to_text(self) -> str:
68
- """Get the replied to text from the payload"""
69
- return self.payload.get("replied_to_text", "")
70
-
71
- @property
72
- def chat_id(self) -> int:
73
- """Get the Telegram chat ID from the payload"""
74
- return self.payload.get("chat_id", 0)
75
-
76
- @property
77
- def message_id(self) -> int:
78
- """Get the Telegram message ID from the payload"""
79
- return self.payload.get("message_id", 0)
80
-
81
- @classmethod
82
- def from_hai_message(cls, message: HaiMessage) -> 'TelegramUserMessageRequestMessage':
83
- payload = message.payload
84
-
85
- return cls.create_message(
86
- message=payload.get("message", ""),
87
- user_id=payload.get("user_id", ""),
88
- username=payload.get("username", ""),
89
- replied_to_text=payload.get("replied_to_text", ""),
90
- chat_id=payload.get("chat_id"),
91
- message_id=payload.get("message_id")
92
- )
93
-
@@ -1,40 +0,0 @@
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
- )
@@ -1,43 +0,0 @@
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", "")
@@ -1,40 +0,0 @@
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='TwitterGetTweetRequestMessage')
8
-
9
- @dataclass
10
- class TwitterGetTweetRequestMessage(HaiMessage):
11
- """Message to request getting a tweet by its ID"""
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) -> 'TwitterGetTweetRequestMessage':
20
- """Create a message requesting to get a tweet by its ID"""
21
- return cls.create(
22
- topic=RequestMessageTopic.TWITTER_GET_TWEET, # 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) -> 'TwitterGetTweetRequestMessage':
35
- """Create a TwitterGetTweetRequestMessage from a HaiMessage"""
36
- payload = message.payload
37
-
38
- return cls.create_message(
39
- tweet_id=payload.get("tweet_id", "")
40
- )