h-message-bus 0.0.5__py3-none-any.whl → 0.0.7__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.
@@ -2,7 +2,9 @@ import json
2
2
  import uuid
3
3
  from dataclasses import dataclass
4
4
  from datetime import datetime
5
- from typing import Dict, Any
5
+ from typing import Dict, Any, TypeVar
6
+
7
+ T = TypeVar('T', bound='HaiMessage')
6
8
 
7
9
 
8
10
  @dataclass
@@ -35,7 +37,7 @@ class HaiMessage:
35
37
  self.timestamp = datetime.utcnow().isoformat()
36
38
 
37
39
  @classmethod
38
- def create(cls, topic: str, payload: Dict[Any, Any]) -> 'HaiMessage':
40
+ def create(cls, topic: str, payload: Dict[Any, Any]) -> T:
39
41
  """Factory method to create a new domain message."""
40
42
  return cls(
41
43
  id=str(uuid.uuid4()),
@@ -1,7 +1,7 @@
1
1
  from enum import Enum
2
2
 
3
3
 
4
- class Topic(str, Enum):
4
+ class MessageTopic(str, Enum):
5
5
  """
6
6
  Represents a collection of predefined topics as an enumeration.
7
7
 
@@ -14,11 +14,20 @@ class Topic(str, Enum):
14
14
 
15
15
  """
16
16
  # AI to Telegram
17
- AI_SEND_TG_CHAT_MESSAGE = "hai.ai.tg.chat.send"
17
+ AI_SEND_TG_CHAT_SEND = "hai.ai.tg.chat.send"
18
18
 
19
19
  # AI to vector database
20
20
  AI_VECTORS_SAVE = "hai.ai.vectors.save"
21
+
21
22
  AI_VECTORS_QUERY = "hai.ai.vectors.query"
23
+ AI_VECTORS_QUERY_RESPONSE = "hai.ai.vectors.query.response"
24
+
25
+ # AI to twitter
26
+ AI_TWITTER_GET_USER = "hai.ai.twitter.get.user"
27
+ AI_TWITTER_GET_USER_RESPONSE = "hai.ai.twitter.get.user.response"
28
+
22
29
 
23
30
  # TG to AI
24
- TG_SEND_AI_CHAT_MESSAGE = "hai.tg.ai.chat.send"
31
+ TG_SEND_AI_CHAT_SEND = "hai.tg.ai.chat.send"
32
+
33
+
@@ -0,0 +1,27 @@
1
+ from typing import Type, TypeVar, Dict, Any
2
+
3
+ from .topics import MessageTopic
4
+ from ..domain.hai_message import HaiMessage
5
+
6
+ T = TypeVar('T', bound='HaiMessage')
7
+
8
+ class TwitterGetUserRequestMessage(HaiMessage):
9
+ """Message to request Twitter user information"""
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, username: str) -> 'TwitterGetUserRequestMessage':
18
+ """Create a message requesting Twitter user data"""
19
+ return cls.create(
20
+ topic=MessageTopic.AI_TWITTER_GET_USER,
21
+ payload={"username": username},
22
+ )
23
+
24
+ @property
25
+ def username(self) -> str:
26
+ """Get the username from the payload"""
27
+ return self.payload.get("username", "")
@@ -0,0 +1,71 @@
1
+ from typing import Type, TypeVar, Dict, Any, List
2
+
3
+ from .topics import MessageTopic
4
+ from ..domain.hai_message import HaiMessage
5
+
6
+ T = TypeVar('T', bound='HaiMessage')
7
+
8
+ class TwitterGetUserResponseMessage(HaiMessage):
9
+ """Response of Twitter user information request"""
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, user_id: str, screen_name: str, description: str, followers_count: str, like_count: str, is_verified: str, url: str, bio_urls: [str]) -> 'TwitterGetUserResponseMessage':
18
+ """Create a response message from Twitter user information"""
19
+ return cls.create(
20
+ topic=MessageTopic.AI_TWITTER_GET_USER_RESPONSE,
21
+ payload={
22
+ 'id': user_id,
23
+ 'screen_name': screen_name,
24
+ 'description': description,
25
+ 'followers_count': followers_count,
26
+ 'like_count': like_count,
27
+ 'is_verified': is_verified,
28
+ 'url': url,
29
+ 'bio_urls': bio_urls
30
+ })
31
+
32
+ @property
33
+ def user_id(self) -> str:
34
+ """Get user ID"""
35
+ return self.payload.get('id', '')
36
+
37
+ @property
38
+ def screen_name(self) -> str:
39
+ """Get screen name"""
40
+ return self.payload.get('screen_name', '')
41
+
42
+ @property
43
+ def description(self) -> str:
44
+ """Get user description"""
45
+ return self.payload.get('description', '')
46
+
47
+ @property
48
+ def followers_count(self) -> str:
49
+ """Get followers count"""
50
+ return self.payload.get('followers_count', '')
51
+
52
+ @property
53
+ def like_count(self) -> str:
54
+ """Get like count"""
55
+ return self.payload.get('like_count', '')
56
+
57
+ @property
58
+ def is_verified(self) -> str:
59
+ """Get verification status"""
60
+ return self.payload.get('is_verified', '')
61
+
62
+ @property
63
+ def url(self) -> str:
64
+ """Get user URL"""
65
+ return self.payload.get('url', '')
66
+
67
+ @property
68
+ def bio_urls(self) -> List[str]:
69
+ """Get URLs from user bio"""
70
+ return self.payload.get('bio_urls', [])
71
+
@@ -0,0 +1,41 @@
1
+ from typing import Type, TypeVar, Dict, Any
2
+
3
+ from .topics import MessageTopic
4
+ from ..domain.hai_message import HaiMessage
5
+
6
+ T = TypeVar('T', bound='HaiMessage')
7
+
8
+ class VectorReadRequestMessage(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) -> 'VectorReadRequestMessage':
18
+ """Create a message requesting Twitter user data"""
19
+ return cls.create(
20
+ topic=MessageTopic.AI_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", "")
@@ -0,0 +1,35 @@
1
+ from typing import Type, TypeVar, Dict, Any
2
+
3
+ from .topics import MessageTopic
4
+ from ..domain.hai_message import HaiMessage
5
+
6
+ T = TypeVar('T', bound='HaiMessage')
7
+
8
+ class VectorReadResponseMessage(HaiMessage):
9
+ """Response Message from reading vector data"""
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, results: [str], dimensions: [str]) -> 'VectorReadResponseMessage':
18
+ """Create a message requesting Twitter user data"""
19
+ return cls.create(
20
+ topic=MessageTopic.AI_VECTORS_QUERY_RESPONSE,
21
+ payload={
22
+ "dimensions": dimensions,
23
+ "results": results
24
+ },
25
+ )
26
+
27
+ @property
28
+ def dimensions(self) -> list[str]:
29
+ """Returns the dimensions from the message payload"""
30
+ return self.payload.get("dimensions", [])
31
+
32
+ @property
33
+ def results(self) -> list[str]:
34
+ """Returns the results from the message payload"""
35
+ return self.payload.get("results", [])
@@ -0,0 +1,47 @@
1
+ from typing import Type, TypeVar, Dict, Any
2
+
3
+ from .topics import MessageTopic
4
+ from ..domain.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, document_id: str, content: str, metadata: str) -> 'VectorSaveRequestMessage':
18
+ """Create a message requesting Twitter user data"""
19
+ return cls.create(
20
+ topic=MessageTopic.AI_VECTORS_SAVE,
21
+ payload={
22
+ "collection_name": collection_name,
23
+ "document_id": document_id,
24
+ "content": content,
25
+ "metadata": metadata
26
+ },
27
+ )
28
+
29
+ @property
30
+ def collection_name(self) -> str:
31
+ """Get the collection name from payload"""
32
+ return self.payload.get("collection_name")
33
+
34
+ @property
35
+ def document_id(self) -> str:
36
+ """Get the document ID from payload"""
37
+ return self.payload.get("document_id")
38
+
39
+ @property
40
+ def content(self) -> str:
41
+ """Get the content from payload"""
42
+ return self.payload.get("content")
43
+
44
+ @property
45
+ def metadata(self) -> str:
46
+ """Get the metadata from payload"""
47
+ return self.payload.get("metadata")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_message_bus
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: Message bus integration for HAI
5
5
  Author-email: shoebill <shoebill.hai@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -8,12 +8,17 @@ h_message_bus/application/message_processor.py,sha256=-I3yUtGQCxmw7McyCpJFMGfXFC
8
8
  h_message_bus/application/message_publisher.py,sha256=hraRMOjjsAZLQOg09V99TjOuBy9Wu2NUtka7-x63doQ,835
9
9
  h_message_bus/application/message_subcriber.py,sha256=2yqUUHVHtZlA6-zzyHzghdWQ7ZmdcFic5c0xi_rgG-M,741
10
10
  h_message_bus/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- h_message_bus/domain/hai_message.py,sha256=mODVLRx_hgrnK9dbw57MiFATAiRwsgQ2TAOTA7r5Fcc,2108
12
- h_message_bus/domain/topics.py,sha256=a3VfQuItmHMaHaDWf2N9DgU8ASUh3-EHHB12YIJPvNw,769
11
+ h_message_bus/domain/hai_message.py,sha256=b5CfX7hi5uNq77IVnZzEi9iotc4b_U2MNYwV6JY7JcU,2146
12
+ h_message_bus/domain/topics.py,sha256=OW-HbTmvogqYaXb0ugZMSvNj2Qhllwfh7BRVS6m4-CU,990
13
+ h_message_bus/domain/twitter_get_user_request_message.py,sha256=n6_v7s57AqrIErINcwVDnvClPaFolKZ99o4tbG3B4gI,930
14
+ h_message_bus/domain/twitter_get_user_response_message.py,sha256=LnLHZU-_7WUtE81iSxeyErCVGVfbS89biIFpdbND4Lw,2318
15
+ h_message_bus/domain/vector_read_request_message.py,sha256=8LoJhsEdwIIceS8bL05gDcFxMUySK5CzRTgj_TmEeqg,1384
16
+ h_message_bus/domain/vector_read_response_message.py,sha256=sPj-jVifXW8hPkM4lIdcJauQY5RJ4H88iD6DVNxwnQ0,1207
17
+ h_message_bus/domain/vector_save_request_message.py,sha256=jDSzK93M9bOhqtsJbmzLyVsQNOqqXpQIWySC5jyBaTo,1563
13
18
  h_message_bus/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
19
  h_message_bus/infrastructure/nats_client_repository.py,sha256=JURLfrTk6188HLaHUHZItBu8utQb68CznP5oQDrTUKU,3343
15
20
  h_message_bus/infrastructure/nats_config.py,sha256=Yzqqd1bCfmUv_4FOnA1dvqIpakzV0BUL2_nXQcndWvo,1304
16
- h_message_bus-0.0.5.dist-info/METADATA,sha256=WzARheZw0LIDmuCiOqrZFtBx9l6e4tzVEalzVdj2CY8,8833
17
- h_message_bus-0.0.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
18
- h_message_bus-0.0.5.dist-info/top_level.txt,sha256=7feCw9I0yIIqsYsVzUMYvCCmUTOiGX1a5F2VbSkFscc,14
19
- h_message_bus-0.0.5.dist-info/RECORD,,
21
+ h_message_bus-0.0.7.dist-info/METADATA,sha256=5E8RWWFnI1m-dmXFhRyuHhgZ9v24QHvheEE8CSg5tf4,8833
22
+ h_message_bus-0.0.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
23
+ h_message_bus-0.0.7.dist-info/top_level.txt,sha256=7feCw9I0yIIqsYsVzUMYvCCmUTOiGX1a5F2VbSkFscc,14
24
+ h_message_bus-0.0.7.dist-info/RECORD,,