h-message-bus 0.0.26__tar.gz → 0.0.27__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.
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/PKG-INFO +1 -1
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/pyproject.toml +1 -1
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/request_message_topic.py +23 -1
- h_message_bus-0.0.27/src/h_message_bus/domain/models/twitter_message_metadata.py +31 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_clear_request_message.py +26 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_get_all_request_message.py +27 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_get_all_result_response_message.py +45 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_add_request_message.py +64 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_added_response_message.py +69 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_get_request_message.py +39 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_get_result_response_message.py +70 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_update_request_message.py +56 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_nodes_by_property_request_message.py +45 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_nodes_by_property_response_message.py +80 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_query_request_message.py +48 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_relationship_added_request_message.py +63 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/tg_message_request_message.py +1 -1
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/tg_user_message_reply_request_message.py +1 -1
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/twitter_user_tweets_request_message.py +63 -0
- h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/twitter_user_tweets_response_message.py +89 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus.egg-info/PKG-INFO +1 -1
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus.egg-info/SOURCES.txt +15 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/README.md +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/setup.cfg +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/adapters/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/adapters/nats_message_adapter.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/adapters/nats_publisher_adapter.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/adapters/nats_subscriber_adapter.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/application/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/application/message_processor.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/application/message_publisher.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/application/message_subcriber.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/event_messages/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/event_message_topic.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/hai_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/twitter_user_metadata.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/vector_collection_metadata.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/vector_query_answer.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/tg_user_message_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/twitter_get_user_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/twitter_get_user_response_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/twitter_get_users_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/twitter_get_users_response_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/vector_query_collection_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/vector_query_collection_response_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/vector_read_metadata_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/vector_read_metadata_response_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/vector_save_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/web_get_docs_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/web_search_request_message.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/infrastructure/__init__.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/infrastructure/nats_client_repository.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/infrastructure/nats_config.py +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus.egg-info/dependency_links.txt +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus.egg-info/requires.txt +0 -0
- {h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus.egg-info/top_level.txt +0 -0
@@ -32,6 +32,8 @@ class RequestMessageTopic(str, Enum):
|
|
32
32
|
TWITTER_GET_USER_RESPONSE = "hai.twitter.get.user.response"
|
33
33
|
TWITTER_GET_USERS = "hai.twitter.get.users"
|
34
34
|
TWITTER_GET_USERS_RESPONSE = "hai.twitter.get.users.response"
|
35
|
+
TWITTER_GET_USER_TWEETS = "hai.twitter.get.user.tweets"
|
36
|
+
TWITTER_GET_USER_TWEETS_RESPONSE = "hai.twitter.get.user.tweets.response"
|
35
37
|
|
36
38
|
TWITTER_USER_SEND_AI_CHAT_SEND = "hai.twitter.user.chat.send"
|
37
39
|
TWITTER_USER_SEND_AI_CHAT_SEND_RESPONSE = "hai.twitter.user.chat.send.response"
|
@@ -44,4 +46,24 @@ class RequestMessageTopic(str, Enum):
|
|
44
46
|
WEB_GET_DOCS_RESPONSE = "hai.tools.web.get.docs.response"
|
45
47
|
|
46
48
|
WEB_FIND_RELATED = "hai.tools.web.find.related"
|
47
|
-
WEB_FIND_RELATED_RESPONSE = "hai.tools.web.find.related.response"
|
49
|
+
WEB_FIND_RELATED_RESPONSE = "hai.tools.web.find.related.response"
|
50
|
+
|
51
|
+
GRAPH_NODE_ADD = "hai.graph.node.add"
|
52
|
+
GRAPH_NODE_UPDATE = "hai.graph.node.update"
|
53
|
+
GRAPH_NODE_GET = "hai.graph.node.get"
|
54
|
+
GRAPH_NODE_DELETE = "hai.graph.node.delete"
|
55
|
+
GRAPH_RELATIONSHIP_ADD = "hai.graph.relationship.add"
|
56
|
+
GRAPH_RELATIONSHIP_DELETE = "hai.graph.relationship.delete"
|
57
|
+
GRAPH_QUERY = "hai.graph.query"
|
58
|
+
GRAPH_CLEAR = "hai.graph.clear"
|
59
|
+
GRAPH_GET_ALL = "hai.graph.get.all"
|
60
|
+
GRAPH_NODES_BY_PROPERTY = "hai.graph.nodes.by.property"
|
61
|
+
|
62
|
+
GRAPH_NODE_ADD_RESPONSE = "hai.graph.node.add.response"
|
63
|
+
GRAPH_NODE_UPDATE_RESPONSE = "hai.graph.node.update.response"
|
64
|
+
GRAPH_NODE_GET_RESPONSE = "hai.graph.node.get.response"
|
65
|
+
GRAPH_RELATIONSHIP_ADD_RESPONSE = "hai.graph.relationship.add.response"
|
66
|
+
GRAPH_QUERY_RESPONSE = "hai.graph.query.response"
|
67
|
+
GRAPH_CLEAR_RESPONSE = "hai.graph.clear.response"
|
68
|
+
GRAPH_GET_ALL_RESPONSE = "hai.graph.get.all.response"
|
69
|
+
GRAPH_NODES_BY_PROPERTY_RESPONSE = "hai.graph.nodes.by.property.response"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from src.h_message_bus.domain.models.twitter_user_metadata import TwitterUserMetadata
|
2
|
+
|
3
|
+
|
4
|
+
class TwitterMessageMetaData:
|
5
|
+
def __init__(self, tweet_id: str, user: TwitterUserMetadata, message: str, created_at: str, view_count: int, retweet_count: int, reply_count: int):
|
6
|
+
self.tweet_id = tweet_id
|
7
|
+
self.message = message
|
8
|
+
self.user = user
|
9
|
+
self.created_at = created_at,
|
10
|
+
self.view_count = view_count
|
11
|
+
self.retweet_count = retweet_count
|
12
|
+
self.reply_count = reply_count
|
13
|
+
|
14
|
+
def to_dict(self) -> dict:
|
15
|
+
"""
|
16
|
+
Convert TwitterMessage instance to a dictionary.
|
17
|
+
|
18
|
+
Returns:
|
19
|
+
dict: A dictionary representation of the TwitterMessage instance.
|
20
|
+
If the user attribute is a TwitterUser instance, it will be converted
|
21
|
+
to a dictionary using its __dict__ attribute.
|
22
|
+
"""
|
23
|
+
return {
|
24
|
+
'tweet_id': self.tweet_id,
|
25
|
+
'message': self.message,
|
26
|
+
'created_at': self.created_at,
|
27
|
+
'view_count': self.view_count,
|
28
|
+
'retweet_count': self.retweet_count,
|
29
|
+
'reply_count': self.reply_count,
|
30
|
+
'user': self.user.to_dict()
|
31
|
+
}
|
@@ -0,0 +1,26 @@
|
|
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()
|
h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_get_all_request_message.py
ADDED
@@ -0,0 +1,27 @@
|
|
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()
|
@@ -0,0 +1,45 @@
|
|
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
|
+
)
|
h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_add_request_message.py
ADDED
@@ -0,0 +1,64 @@
|
|
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
|
+
)
|
h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_added_response_message.py
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
from typing import TypeVar, Dict, Any, Type, Optional
|
2
|
+
|
3
|
+
from ..models.request_message_topic import RequestMessageTopic
|
4
|
+
from ...domain.models.hai_message import HaiMessage
|
5
|
+
|
6
|
+
T = TypeVar('T', bound='HaiMessage')
|
7
|
+
|
8
|
+
class 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
|
+
)
|
h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_get_request_message.py
ADDED
@@ -0,0 +1,39 @@
|
|
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
|
+
)
|
@@ -0,0 +1,70 @@
|
|
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
|
+
)
|
h_message_bus-0.0.27/src/h_message_bus/domain/request_messages/graph_node_update_request_message.py
ADDED
@@ -0,0 +1,56 @@
|
|
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
|
+
)
|
@@ -0,0 +1,45 @@
|
|
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
|
+
)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
from typing import TypeVar, Dict, Any, Type, List
|
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 GraphNodesByPropertyResponseMessage(HaiMessage):
|
9
|
+
"""Response message containing 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,
|
18
|
+
nodes: List[Dict], relationships: List[Dict],
|
19
|
+
success: bool = True) -> 'GraphNodesByPropertyResponseMessage':
|
20
|
+
"""
|
21
|
+
Create a response message with nodes having a specific property value and their relationships
|
22
|
+
|
23
|
+
Args:
|
24
|
+
property_name: The property name that was queried
|
25
|
+
property_value: The property value that was queried
|
26
|
+
nodes: List of node dictionaries
|
27
|
+
relationships: List of relationship dictionaries
|
28
|
+
success: Whether the operation was successful
|
29
|
+
|
30
|
+
Returns:
|
31
|
+
A response message with the query results
|
32
|
+
"""
|
33
|
+
return cls.create(
|
34
|
+
topic=RequestMessageTopic.GRAPH_NODES_BY_PROPERTY_RESPONSE,
|
35
|
+
payload={
|
36
|
+
"property_name": property_name,
|
37
|
+
"property_value": property_value,
|
38
|
+
"nodes": nodes,
|
39
|
+
"relationships": relationships,
|
40
|
+
"success": success
|
41
|
+
},
|
42
|
+
)
|
43
|
+
|
44
|
+
@property
|
45
|
+
def property_name(self) -> str:
|
46
|
+
"""Get the property name from the payload"""
|
47
|
+
return self.payload.get("property_name")
|
48
|
+
|
49
|
+
@property
|
50
|
+
def property_value(self) -> any:
|
51
|
+
"""Get the property value from the payload"""
|
52
|
+
return self.payload.get("property_value")
|
53
|
+
|
54
|
+
@property
|
55
|
+
def nodes(self) -> List[Dict]:
|
56
|
+
"""Get the list of nodes from the payload"""
|
57
|
+
return self.payload.get("nodes", [])
|
58
|
+
|
59
|
+
@property
|
60
|
+
def relationships(self) -> List[Dict]:
|
61
|
+
"""Get the list of relationships from the payload"""
|
62
|
+
return self.payload.get("relationships", [])
|
63
|
+
|
64
|
+
@property
|
65
|
+
def success(self) -> bool:
|
66
|
+
"""Check if the query was successful"""
|
67
|
+
return self.payload.get("success", False)
|
68
|
+
|
69
|
+
@classmethod
|
70
|
+
def from_hai_message(cls, message: HaiMessage) -> 'GraphNodesByPropertyResponseMessage':
|
71
|
+
# Extract the necessary fields from the message payload
|
72
|
+
payload = message.payload
|
73
|
+
|
74
|
+
return cls.create_message(
|
75
|
+
property_name=payload.get("property_name", ''),
|
76
|
+
property_value=payload.get("property_value"),
|
77
|
+
nodes=payload.get("nodes", []),
|
78
|
+
relationships=payload.get("relationships", []),
|
79
|
+
success=payload.get("success", False)
|
80
|
+
)
|
@@ -0,0 +1,48 @@
|
|
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
|
+
)
|
@@ -0,0 +1,63 @@
|
|
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
|
+
)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
from dataclasses import dataclass
|
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
|
+
@dataclass
|
10
|
+
class TwitterUserTweetsRequestMessage(HaiMessage):
|
11
|
+
"""Message to request tweets from 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, max_results: int = 100,
|
20
|
+
include_replies: bool = False,
|
21
|
+
include_retweets: bool = False) -> 'TwitterUserTweetsRequestMessage':
|
22
|
+
"""Create a message requesting tweets from a Twitter user"""
|
23
|
+
return cls.create(
|
24
|
+
topic=RequestMessageTopic.TWITTER_GET_USER_TWEETS,
|
25
|
+
payload={
|
26
|
+
"user_id": user_id,
|
27
|
+
"max_results": max_results,
|
28
|
+
"include_replies": include_replies,
|
29
|
+
"include_retweets": include_retweets
|
30
|
+
},
|
31
|
+
)
|
32
|
+
|
33
|
+
@property
|
34
|
+
def user_id(self) -> str:
|
35
|
+
"""Get the user ID from the payload"""
|
36
|
+
return self.payload.get("user_id")
|
37
|
+
|
38
|
+
@property
|
39
|
+
def max_results(self) -> int:
|
40
|
+
"""Get the maximum number of results from the payload"""
|
41
|
+
return self.payload.get("max_results", 100)
|
42
|
+
|
43
|
+
@property
|
44
|
+
def include_replies(self) -> bool:
|
45
|
+
"""Get whether to include replies from the payload"""
|
46
|
+
return self.payload.get("include_replies", False)
|
47
|
+
|
48
|
+
@property
|
49
|
+
def include_retweets(self) -> bool:
|
50
|
+
"""Get whether to include retweets from the payload"""
|
51
|
+
return self.payload.get("include_retweets", False)
|
52
|
+
|
53
|
+
@classmethod
|
54
|
+
def from_hai_message(cls, message: HaiMessage) -> 'TwitterUserTweetsRequestMessage':
|
55
|
+
"""Create a TwitterUserTweetsRequestMessage from a HaiMessage"""
|
56
|
+
payload = message.payload
|
57
|
+
|
58
|
+
return cls.create_message(
|
59
|
+
user_id=payload.get("user_id", ""),
|
60
|
+
max_results=payload.get("max_results", 100),
|
61
|
+
include_replies=payload.get("include_replies", False),
|
62
|
+
include_retweets=payload.get("include_retweets", False)
|
63
|
+
)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
from typing import TypeVar, Dict, Any, Type, List
|
3
|
+
|
4
|
+
from ..models.request_message_topic import RequestMessageTopic
|
5
|
+
from ..models.twitter_message_metadata import TwitterMessageMetaData
|
6
|
+
from ...domain.models.hai_message import HaiMessage
|
7
|
+
|
8
|
+
T = TypeVar('T', bound='HaiMessage')
|
9
|
+
@dataclass
|
10
|
+
class TwitterUserTweetsResponseMessage(HaiMessage):
|
11
|
+
"""Message containing tweets from 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, tweets: List[Dict[str, Any]],
|
20
|
+
success: bool = True, error: str = None) -> 'TwitterUserTweetsResponseMessage':
|
21
|
+
"""Create a message with tweets from a Twitter user"""
|
22
|
+
return cls.create(
|
23
|
+
topic=RequestMessageTopic.TWITTER_GET_USER_TWEETS_RESPONSE,
|
24
|
+
payload={
|
25
|
+
"user_id": user_id,
|
26
|
+
"tweets": tweets,
|
27
|
+
"success": success,
|
28
|
+
"error": error
|
29
|
+
},
|
30
|
+
)
|
31
|
+
|
32
|
+
@property
|
33
|
+
def user_id(self) -> str:
|
34
|
+
"""Get the user ID from the payload"""
|
35
|
+
return self.payload.get("user_id")
|
36
|
+
|
37
|
+
@property
|
38
|
+
def tweets(self) -> List[Dict[str, Any]]:
|
39
|
+
"""Get the tweets from the payload"""
|
40
|
+
return self.payload.get("tweets", [])
|
41
|
+
|
42
|
+
@property
|
43
|
+
def success(self) -> bool:
|
44
|
+
"""Get whether the request was successful"""
|
45
|
+
return self.payload.get("success", False)
|
46
|
+
|
47
|
+
@property
|
48
|
+
def error(self) -> str:
|
49
|
+
"""Get any error message"""
|
50
|
+
return self.payload.get("error")
|
51
|
+
|
52
|
+
@classmethod
|
53
|
+
def from_hai_message(cls, message: HaiMessage) -> 'TwitterUserTweetsResponseMessage':
|
54
|
+
"""Create a TwitterUserTweetsResponseMessage from a HaiMessage"""
|
55
|
+
payload = message.payload
|
56
|
+
|
57
|
+
return cls.create_message(
|
58
|
+
user_id=payload.get("user_id", ""),
|
59
|
+
tweets=payload.get("tweets", []),
|
60
|
+
success=payload.get("success", False),
|
61
|
+
error=payload.get("error")
|
62
|
+
)
|
63
|
+
|
64
|
+
@classmethod
|
65
|
+
def from_twitter_messages(cls, user_id: str,
|
66
|
+
twitter_messages: List[TwitterMessageMetaData]) -> 'TwitterUserTweetsResponseMessage':
|
67
|
+
"""Create a response message from a list of TwitterMessage objects"""
|
68
|
+
tweets = []
|
69
|
+
|
70
|
+
for message in twitter_messages:
|
71
|
+
user = message.user
|
72
|
+
|
73
|
+
tweet_data = {
|
74
|
+
"tweet_id": str(message.tweet_id),
|
75
|
+
"message": message.message,
|
76
|
+
"created_at": message.created_at.isoformat() if message.created_at else None,
|
77
|
+
"view_count": message.view_count,
|
78
|
+
"retweet_count": message.retweet_count,
|
79
|
+
"reply_count": message.reply_count,
|
80
|
+
"user": message.user.to_dict() if user else None,
|
81
|
+
}
|
82
|
+
|
83
|
+
tweets.append(tweet_data)
|
84
|
+
|
85
|
+
return cls.create_message(
|
86
|
+
user_id=user_id,
|
87
|
+
tweets=tweets,
|
88
|
+
success=True
|
89
|
+
)
|
@@ -21,10 +21,23 @@ src/h_message_bus/domain/models/__init__.py
|
|
21
21
|
src/h_message_bus/domain/models/event_message_topic.py
|
22
22
|
src/h_message_bus/domain/models/hai_message.py
|
23
23
|
src/h_message_bus/domain/models/request_message_topic.py
|
24
|
+
src/h_message_bus/domain/models/twitter_message_metadata.py
|
24
25
|
src/h_message_bus/domain/models/twitter_user_metadata.py
|
25
26
|
src/h_message_bus/domain/models/vector_collection_metadata.py
|
26
27
|
src/h_message_bus/domain/models/vector_query_answer.py
|
27
28
|
src/h_message_bus/domain/request_messages/__init__.py
|
29
|
+
src/h_message_bus/domain/request_messages/graph_clear_request_message.py
|
30
|
+
src/h_message_bus/domain/request_messages/graph_get_all_request_message.py
|
31
|
+
src/h_message_bus/domain/request_messages/graph_get_all_result_response_message.py
|
32
|
+
src/h_message_bus/domain/request_messages/graph_node_add_request_message.py
|
33
|
+
src/h_message_bus/domain/request_messages/graph_node_added_response_message.py
|
34
|
+
src/h_message_bus/domain/request_messages/graph_node_get_request_message.py
|
35
|
+
src/h_message_bus/domain/request_messages/graph_node_get_result_response_message.py
|
36
|
+
src/h_message_bus/domain/request_messages/graph_node_update_request_message.py
|
37
|
+
src/h_message_bus/domain/request_messages/graph_nodes_by_property_request_message.py
|
38
|
+
src/h_message_bus/domain/request_messages/graph_nodes_by_property_response_message.py
|
39
|
+
src/h_message_bus/domain/request_messages/graph_query_request_message.py
|
40
|
+
src/h_message_bus/domain/request_messages/graph_relationship_added_request_message.py
|
28
41
|
src/h_message_bus/domain/request_messages/tg_message_request_message.py
|
29
42
|
src/h_message_bus/domain/request_messages/tg_user_message_reply_request_message.py
|
30
43
|
src/h_message_bus/domain/request_messages/tg_user_message_request_message.py
|
@@ -32,6 +45,8 @@ src/h_message_bus/domain/request_messages/twitter_get_user_request_message.py
|
|
32
45
|
src/h_message_bus/domain/request_messages/twitter_get_user_response_message.py
|
33
46
|
src/h_message_bus/domain/request_messages/twitter_get_users_request_message.py
|
34
47
|
src/h_message_bus/domain/request_messages/twitter_get_users_response_message.py
|
48
|
+
src/h_message_bus/domain/request_messages/twitter_user_tweets_request_message.py
|
49
|
+
src/h_message_bus/domain/request_messages/twitter_user_tweets_response_message.py
|
35
50
|
src/h_message_bus/domain/request_messages/vector_query_collection_request_message.py
|
36
51
|
src/h_message_bus/domain/request_messages/vector_query_collection_response_message.py
|
37
52
|
src/h_message_bus/domain/request_messages/vector_read_metadata_request_message.py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/adapters/nats_message_adapter.py
RENAMED
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/adapters/nats_publisher_adapter.py
RENAMED
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/adapters/nats_subscriber_adapter.py
RENAMED
File without changes
|
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/application/message_processor.py
RENAMED
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/application/message_publisher.py
RENAMED
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/application/message_subcriber.py
RENAMED
File without changes
|
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/event_messages/__init__.py
RENAMED
File without changes
|
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/event_message_topic.py
RENAMED
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/hai_message.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/models/vector_query_answer.py
RENAMED
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/domain/request_messages/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus/infrastructure/nats_config.py
RENAMED
File without changes
|
{h_message_bus-0.0.26 → h_message_bus-0.0.27}/src/h_message_bus.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|