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,54 +0,0 @@
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", "")
@@ -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='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
- )
@@ -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='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,73 +0,0 @@
1
- from typing import Dict, Any, Type, TypeVar, Optional, Literal, cast
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 TwitterSearchRequestMessage(HaiMessage):
10
- """Message to request Twitter search"""
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(
19
- cls,
20
- query: str,
21
- max_results: int = 10,
22
- min_view_count: int = 50,
23
- sort_order: Literal["relevancy", "recency"] = "relevancy"
24
- ) -> 'TwitterSearchRequestMessage':
25
- """Create a message requesting Twitter search"""
26
- return cls.create(
27
- topic=RequestMessageTopic.TWITTER_SEARCH,
28
- payload={
29
- "query": query,
30
- "max_results": max_results,
31
- "min_view_count": min_view_count,
32
- "sort_order": sort_order
33
- },
34
- )
35
-
36
- @property
37
- def query(self) -> str:
38
- """Get the search query from the payload"""
39
- return self.payload.get("query", "")
40
-
41
- @property
42
- def max_results(self) -> int:
43
- """Get the maximum number of results from the payload"""
44
- return self.payload.get("max_results", 10)
45
-
46
- @property
47
- def min_view_count(self) -> int:
48
- """Get the minimum view count from the payload"""
49
- return self.payload.get("min_view_count", 50)
50
-
51
- @property
52
- def sort_order(self) -> Literal["relevancy", "recency"]:
53
- """Get the sort order from the payload"""
54
- sort_order_str = self.payload.get("sort_order", "relevancy")
55
- if sort_order_str not in ("relevancy", "recency"):
56
- sort_order_str = "relevancy"
57
- return cast(Literal["relevancy", "recency"], sort_order_str)
58
-
59
- @classmethod
60
- def from_hai_message(cls, message: HaiMessage) -> 'TwitterSearchRequestMessage':
61
- """Create a TwitterSearchRequestMessage from a HaiMessage"""
62
- payload = message.payload
63
- query = payload.get("query", "")
64
- max_results = payload.get("max_results", 10)
65
- min_view_count = payload.get("min_view_count", 50)
66
- sort_order = payload.get("sort_order", "relevancy")
67
-
68
- return cls.create_message(
69
- query=query,
70
- max_results=max_results,
71
- min_view_count=min_view_count,
72
- sort_order=sort_order
73
- )
@@ -1,73 +0,0 @@
1
- from typing import Dict, Any, Type, TypeVar, List, Optional
2
- import json
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 TwitterSearchResponseMessage(HaiMessage):
11
- """Message containing Twitter search results"""
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(
20
- cls,
21
- query: str,
22
- results: List[Dict[str, Any]],
23
- result_count: int,
24
- request_id: str
25
- ) -> 'TwitterSearchResponseMessage':
26
- """Create a message containing Twitter search results"""
27
- return cls.create(
28
- topic=RequestMessageTopic.TWITTER_SEARCH_RESPONSE,
29
- payload={
30
- "query": query,
31
- "results": json.dumps(results),
32
- "result_count": result_count,
33
- "request_id": request_id
34
- },
35
- )
36
-
37
- @property
38
- def query(self) -> str:
39
- """Get the search query from the payload"""
40
- return self.payload.get("query", "")
41
-
42
- @property
43
- def result_count(self) -> int:
44
- """Get the number of results from the payload"""
45
- return self.payload.get("result_count", 0)
46
-
47
- @property
48
- def request_id(self) -> str:
49
- """Get the original request ID from the payload"""
50
- return self.payload.get("request_id", "")
51
-
52
- @property
53
- def results(self) -> List[Dict[str, Any]]:
54
- """Get the search results from the payload"""
55
- results_json = self.payload.get("results", "[]")
56
- return json.loads(results_json)
57
-
58
- @classmethod
59
- def from_hai_message(cls, message: HaiMessage) -> 'TwitterSearchResponseMessage':
60
- """Create a TwitterSearchResponseMessage from a HaiMessage"""
61
- payload = message.payload
62
- query = payload.get("query", "")
63
- results_json = payload.get("results", "[]")
64
- results = json.loads(results_json)
65
- result_count = payload.get("result_count", 0)
66
- request_id = payload.get("request_id", "")
67
-
68
- return cls.create_message(
69
- query=query,
70
- results=results,
71
- result_count=result_count,
72
- request_id=request_id
73
- )
@@ -1,63 +0,0 @@
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
- )
@@ -1,89 +0,0 @@
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,
77
- "view_count": message.view_count,
78
- "retweet_count": message.retweet_count,
79
- "reply_count": message.reply_count,
80
- "user": message.user,
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
- )
@@ -1,51 +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
- class VectorQueryCollectionRequestMessage(HaiMessage):
9
- """Message to read data from vector store"""
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, collection_name: str, query: str, top_n: str) -> 'VectorQueryCollectionRequestMessage':
18
- """Create a message requesting Twitter user data"""
19
- return cls.create(
20
- topic=RequestMessageTopic.VECTORS_QUERY,
21
- payload={
22
- "collection_name": collection_name,
23
- "query": query,
24
- "top_n": top_n
25
- },
26
- )
27
-
28
- @property
29
- def collection_name(self) -> str:
30
- """Get the collection name from the message payload"""
31
- return self.payload.get("collection_name", "")
32
-
33
- @property
34
- def query(self) -> str:
35
- """Get the query from the message payload"""
36
- return self.payload.get("query", "")
37
-
38
- @property
39
- def top_n(self) -> str:
40
- """Get the top_n value from the message payload"""
41
- return self.payload.get("top_n", "")
42
-
43
- @classmethod
44
- def from_hai_message(cls, message: HaiMessage) -> 'VectorQueryCollectionRequestMessage':
45
- payload = message.payload
46
-
47
- return cls.create_message(
48
- collection_name=payload.get("collection_name", ""),
49
- query=payload.get("query", ""),
50
- top_n=payload.get("top_n", "")
51
- )
@@ -1,47 +0,0 @@
1
- import json
2
- from typing import Type, TypeVar, Dict, Any
3
-
4
- from ..models.request_message_topic import RequestMessageTopic
5
- from ..models.vector_query_answer import VectorQueryAnswer
6
- from ...domain.models.hai_message import HaiMessage
7
-
8
- T = TypeVar('T', bound='HaiMessage')
9
-
10
- class VectorQueryCollectionResponseMessage(HaiMessage):
11
- """Response Message from reading vector data"""
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, result: dict[int, dict[str, str]]) -> 'VectorQueryCollectionResponseMessage':
20
- """Create a message requesting Twitter user data"""
21
- result_list = json.dumps(result)
22
- return cls.create(
23
- topic=RequestMessageTopic.VECTORS_QUERY_RESPONSE,
24
- payload={
25
- "result": result_list,
26
- },
27
- )
28
-
29
- @property
30
- def results(self) -> list[VectorQueryAnswer]:
31
- """Returns the results from the message payload"""
32
- results = self.payload.get("result", "")
33
- meta_dict = json.loads(results)
34
- response_list = []
35
- for meta in meta_dict:
36
- response_list.append(VectorQueryAnswer.from_dict(meta))
37
- return response_list
38
-
39
- @classmethod
40
- def from_hai_message(cls, message: HaiMessage) -> 'VectorQueryCollectionResponseMessage':
41
- # Extract necessary fields from the message payload
42
- payload = message.payload
43
- result = payload.get("result", "")
44
- result_list = json.loads(result)
45
- return cls.create_message(
46
- result=result_list
47
- )
@@ -1,25 +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
- class VectorReadMetaDataRequestMessage(HaiMessage):
9
-
10
- @classmethod
11
- def create(cls: Type[T], topic: str, payload: Dict[Any, Any]) -> T:
12
- """Create a message - inherited from HaiMessage"""
13
- return super().create(topic=topic, payload=payload)
14
-
15
- @classmethod
16
- def create_message(cls) -> 'VectorReadMetaDataRequestMessage':
17
- """Create a message requesting Twitter user data"""
18
- return cls.create(
19
- topic=RequestMessageTopic.VECTORS_METADATA_READ,
20
- payload={},
21
- )
22
-
23
- @classmethod
24
- def from_hai_message(cls) -> 'VectorReadMetaDataRequestMessage':
25
- return cls.create_message()
@@ -1,45 +0,0 @@
1
- import json
2
- from typing import Type, TypeVar, Dict, Any, List
3
-
4
- from ..models.request_message_topic import RequestMessageTopic
5
- from ..models.vector_collection_metadata import VectorCollectionMetadata
6
- from ...domain.models.hai_message import HaiMessage
7
-
8
-
9
- T = TypeVar('T', bound='HaiMessage')
10
-
11
- class VectorReadMetaDataResponseMessage(HaiMessage):
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, metadata: List[dict[str, str]]) -> 'VectorReadMetaDataResponseMessage':
20
- metadata_result = json.dumps(metadata)
21
- return cls.create(
22
- topic=RequestMessageTopic.VECTORS_METADATA_READ_RESPONSE,
23
- payload={
24
- "metadata": metadata_result,
25
- },
26
- )
27
-
28
- @property
29
- def metadata(self) -> List[VectorCollectionMetadata]:
30
- """Get the collection name from the message payload"""
31
- metadata = self.payload.get("metadata", "")
32
- meta_dict = json.loads(metadata)
33
- response_list = []
34
- for meta in meta_dict:
35
- response_list.append(VectorCollectionMetadata.from_dict(meta))
36
- return response_list
37
-
38
- @classmethod
39
- def from_hai_message(cls, message: HaiMessage) -> 'VectorReadMetaDataResponseMessage':
40
- payload = message.payload
41
- metadata = payload.get("metadata", "")
42
- meta_list = json.loads(metadata)
43
- return cls.create_message(
44
- metadata=meta_list
45
- )
@@ -1,66 +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
- class VectorSaveRequestMessage(HaiMessage):
9
- """Message to data in vector store"""
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, collection_name: str, collection_metadata: dict[str,str], document_id: str, content: str, metadata: dict[str,str]) -> 'VectorSaveRequestMessage':
18
- """Create a message requesting Twitter user data"""
19
- return cls.create(
20
- topic=RequestMessageTopic.VECTORS_SAVE,
21
- payload={
22
- "collection_name": collection_name,
23
- "collection_metadata": collection_metadata,
24
- "document_id": document_id,
25
- "content": content,
26
- "metadata": metadata
27
- },
28
- )
29
-
30
- @property
31
- def collection_name(self) -> str:
32
- """Get the collection name from the payload"""
33
- return self.payload.get("collection_name")
34
-
35
- @property
36
- def collection_metadata(self) -> dict[str, str]:
37
- """Get the collection name from the payload"""
38
- return self.payload.get("collection_metadata")
39
-
40
- @property
41
- def document_id(self) -> str:
42
- """Get the document ID from the payload"""
43
- return self.payload.get("document_id")
44
-
45
- @property
46
- def content(self) -> str:
47
- """Get the content from the payload"""
48
- return self.payload.get("content")
49
-
50
- @property
51
- def metadata(self) -> dict[str, str]:
52
- """Get the metadata from the payload"""
53
- return self.payload.get("metadata")
54
-
55
- @classmethod
56
- def from_hai_message(cls, message: HaiMessage) -> 'VectorSaveRequestMessage':
57
- # Extract the necessary fields from the message payload
58
- payload = message.payload
59
-
60
- return cls.create_message(
61
- collection_name=payload.get("collection_name", ''),
62
- collection_metadata=payload.get("collection_metadata", {}),
63
- document_id=payload.get("document_id", ''),
64
- content=payload.get("content", ''),
65
- metadata=payload.get("metadata", {})
66
- )