h-message-bus 0.0.4__py3-none-any.whl → 0.0.6__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,23 @@
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
+
@@ -0,0 +1,30 @@
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 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
+ })
@@ -0,0 +1,26 @@
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
+ )
@@ -0,0 +1,25 @@
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
+ )
@@ -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 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
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_message_bus
3
- Version: 0.0.4
3
+ Version: 0.0.6
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,7 +8,6 @@ Classifier: License :: OSI Approved :: MIT License
8
8
  Classifier: Operating System :: OS Independent
9
9
  Requires-Python: >=3.10
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: python-dotenv~=1.1.0
12
11
  Requires-Dist: nats-py~=2.10.0
13
12
  Provides-Extra: dev
14
13
  Requires-Dist: pytest; extra == "dev"
@@ -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=qDyx0Mfm9jkjfk7pmMFu5Jln_lIsCYveSYbVzeVspuI,785
14
+ h_message_bus/domain/twitter_get_user_response_message.py,sha256=YtQBdKZzEGRi2TSj5WW7qTPVLVjBWn9eAfn1UutK8WQ,1237
15
+ h_message_bus/domain/vector_read_request_message.py,sha256=XqrWYYTJbEZAcimIwdKuz3N1xUaEwrB1WDOl3buQn_Y,908
16
+ h_message_bus/domain/vector_read_response_message.py,sha256=shgNrwQN_wmAxPIPqgcv16svTMYNLtCZy2mJoWEdD7Q,872
17
+ h_message_bus/domain/vector_save_request_message.py,sha256=L_pALwa-afqzyFGJ-ayVyzApeVNd920OVm6cf7eYyVc,978
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.4.dist-info/METADATA,sha256=Jf2par702nSA2LQeoCenp71b77mdkpgHCZJKnT68GuQ,8870
17
- h_message_bus-0.0.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
18
- h_message_bus-0.0.4.dist-info/top_level.txt,sha256=7feCw9I0yIIqsYsVzUMYvCCmUTOiGX1a5F2VbSkFscc,14
19
- h_message_bus-0.0.4.dist-info/RECORD,,
21
+ h_message_bus-0.0.6.dist-info/METADATA,sha256=Q2WcM242VKQ90GoNGpC4HvVNlpdCQjD39okmk8CDouc,8833
22
+ h_message_bus-0.0.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
23
+ h_message_bus-0.0.6.dist-info/top_level.txt,sha256=7feCw9I0yIIqsYsVzUMYvCCmUTOiGX1a5F2VbSkFscc,14
24
+ h_message_bus-0.0.6.dist-info/RECORD,,