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
@@ -60,7 +60,7 @@ class NatsClientRepository:
60
60
  raise ConnectionError("Could not establish connection to NATS server.")
61
61
 
62
62
  async def publish(self, subject: str, payload: bytes, retries: int = 3) -> None:
63
- """Publish raw message to NATS with retries and backoff."""
63
+ """Publish a raw message to NATS with retries and backoff."""
64
64
  for attempt in range(retries):
65
65
  try:
66
66
  await self._ensure_connected()
@@ -83,7 +83,7 @@ class NatsClientRepository:
83
83
  return None
84
84
 
85
85
  async def request(self, subject: str, payload: bytes, timeout: float = 2.0, retries: int = 3) -> Optional[bytes]:
86
- """Send a request and get raw response with retries and backoff."""
86
+ """Send a request and get a raw response with retries and backoff."""
87
87
  for attempt in range(retries):
88
88
  try:
89
89
  await self._ensure_connected()
@@ -4,7 +4,7 @@ from dataclasses import dataclass
4
4
  @dataclass
5
5
  class NatsConfig:
6
6
  """
7
- Configuration class for NATS client.
7
+ Configuration class for the NATS client.
8
8
 
9
9
  This class encapsulates the configuration options required for connecting and
10
10
  interacting with a NATS (NATS.io) server. It includes options for setting
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h_message_bus
3
- Version: 0.0.40
3
+ Version: 0.0.41
4
4
  Summary: Message bus integration for HAI
5
5
  Author-email: shoebill <shoebill.hai@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -40,18 +40,18 @@ pip install h_message_bus
40
40
 
41
41
  ## Topics
42
42
 
43
- H Message Bus includes predefined topics following the convention: `hai.[source].[destination].[action]`
43
+ H Message Bus uses topic strings for message routing. It's recommended to follow the convention: `hai.[source].[destination].[action]`
44
44
 
45
- Available topics:
45
+ Example topics:
46
46
 
47
- | Topic Constant | Topic String | Description |
48
- |---------------------------------|------------------------|-------------------------------------|
49
- | `Topic.AI_SEND_TG_CHAT_MESSAGE` | `hai.ai.tg.chat.send` | AI sending message to Telegram chat |
50
- | `Topic.AI_VECTORS_SAVE` | `hai.ai.vectors.save` | AI saving data to vector database |
51
- | `Topic.AI_VECTORS_QUERY` | `hai.ai.vectors.query` | AI querying vector database |
52
- | `Topic.TG_SEND_AI_CHAT_MESSAGE` | `hai.tg.ai.chat.send` | Telegram sending message to AI |
47
+ | Topic String | Description |
48
+ |------------------------|-------------------------------------|
49
+ | `hai.ai.tg.chat.send` | AI sending message to Telegram chat |
50
+ | `hai.ai.vectors.save` | AI saving data to vector database |
51
+ | `hai.ai.vectors.query` | AI querying vector database |
52
+ | `hai.tg.ai.chat.send` | Telegram sending message to AI |
53
53
 
54
- You can use these predefined topics or create your own topic strings.
54
+ You can use these example topics or create your own topic strings based on your application's needs.
55
55
 
56
56
  ## Quick Start
57
57
 
@@ -68,29 +68,31 @@ docker-compose up -d
68
68
  ```python
69
69
  import asyncio
70
70
  import uuid
71
- from h_message_bus import NatsConfig, NatsPublisherAdapter, HaiMessage, Topic
71
+ from h_message_bus import NatsConfig, NatsPublisherAdapter, HaiMessage, NatsClientRepository
72
72
 
73
73
  async def main():
74
74
  # Configure NATS connection
75
75
  config = NatsConfig(server="nats://localhost:4222")
76
-
76
+
77
+ # Create NATS client repository
78
+ client_repository = NatsClientRepository(config)
79
+
77
80
  # Create publisher adapter
78
- publisher = NatsPublisherAdapter(config)
79
-
81
+ publisher = NatsPublisherAdapter(client_repository)
82
+
80
83
  # Connect to NATS
81
- await publisher.connect()
82
-
83
- # Create and publish a message using a predefined topic
84
+ await client_repository.connect()
85
+
86
+ # Create and publish a message
84
87
  message = HaiMessage(
85
- message_id=str(uuid.uuid4()),
86
- sender="service-a",
87
- topic=Topic.TG_SEND_AI_CHAT_MESSAGE,
88
+ id=str(uuid.uuid4()),
89
+ topic="hai.tg.ai.chat.send",
88
90
  payload={"text": "Hello AI, this is a message from Telegram", "chat_id": 12345}
89
91
  )
90
-
92
+
91
93
  # Publish message
92
94
  await publisher.publish(message)
93
-
95
+
94
96
  # Clean up
95
97
  await publisher.close()
96
98
 
@@ -102,27 +104,34 @@ if __name__ == "__main__":
102
104
 
103
105
  ```python
104
106
  import asyncio
105
- from h_message_bus import NatsConfig, NatsSubscriberAdapter, HaiMessage, Topic
107
+ from h_message_bus import NatsConfig, NatsSubscriberAdapter, HaiMessage, NatsClientRepository, MessageProcessor
106
108
 
107
- async def message_handler(message: HaiMessage):
108
- print(f"Received message: {message.message_id}")
109
- print(f"From: {message.sender}")
110
- print(f"Topic: {message.topic}")
111
- print(f"Payload: {message.payload}")
109
+ class MyMessageProcessor(MessageProcessor):
110
+ async def process(self, message: HaiMessage):
111
+ print(f"Received message: {message.id}")
112
+ print(f"Topic: {message.topic}")
113
+ print(f"Payload: {message.payload}")
114
+ print(f"Timestamp: {message.timestamp}")
112
115
 
113
116
  async def main():
114
117
  # Configure NATS connection
115
118
  config = NatsConfig(server="nats://localhost:4222")
116
-
119
+
120
+ # Create NATS client repository
121
+ client_repository = NatsClientRepository(config)
122
+
117
123
  # Create subscriber
118
- subscriber = NatsSubscriberAdapter(config)
119
-
124
+ subscriber = NatsSubscriberAdapter(client_repository)
125
+
120
126
  # Connect to NATS
121
- await subscriber.connect()
122
-
127
+ await client_repository.connect()
128
+
129
+ # Create message processor
130
+ processor = MyMessageProcessor()
131
+
123
132
  # Subscribe to a topic
124
- await subscriber.subscribe(Topic.TG_SEND_AI_CHAT_MESSAGE, message_handler)
125
-
133
+ await subscriber.subscribe("hai.tg.ai.chat.send", processor)
134
+
126
135
  # Keep the application running
127
136
  try:
128
137
  print("Subscriber running. Press Ctrl+C to exit.")
@@ -130,7 +139,7 @@ async def main():
130
139
  await asyncio.sleep(1)
131
140
  except KeyboardInterrupt:
132
141
  # Clean up
133
- await subscriber.close()
142
+ await client_repository.close()
134
143
 
135
144
  if __name__ == "__main__":
136
145
  asyncio.run(main())
@@ -143,74 +152,91 @@ if __name__ == "__main__":
143
152
  ```python
144
153
  import asyncio
145
154
  import uuid
146
- from h_message_bus import NatsConfig, NatsPublisherAdapter, HaiMessage, Topic
155
+ from h_message_bus import NatsConfig, NatsPublisherAdapter, HaiMessage, NatsClientRepository
147
156
 
148
157
  async def main():
158
+ # Configure NATS connection
149
159
  config = NatsConfig(server="nats://localhost:4222")
150
- publisher = NatsPublisherAdapter(config)
151
-
160
+
161
+ # Create NATS client repository
162
+ client_repository = NatsClientRepository(config)
163
+
164
+ # Create publisher adapter
165
+ publisher = NatsPublisherAdapter(client_repository)
166
+
152
167
  # Connect to NATS
153
- await publisher.connect()
154
-
168
+ await client_repository.connect()
169
+
155
170
  request_message = HaiMessage(
156
- message_id=str(uuid.uuid4()),
157
- sender="client-service",
158
- topic=Topic.AI_VECTORS_QUERY,
171
+ id=str(uuid.uuid4()),
172
+ topic="hai.ai.vectors.query",
159
173
  payload={"query": "find similar documents", "limit": 10}
160
174
  )
161
-
175
+
162
176
  # Send request and wait for response (with timeout)
163
177
  response = await publisher.request(request_message, timeout=5.0)
164
-
178
+
165
179
  if response:
166
180
  print(f"Received response: {response.payload}")
167
181
  else:
168
182
  print("Request timed out")
169
-
170
- await publisher.close()
183
+
184
+ # Clean up
185
+ await client_repository.close()
171
186
 
172
187
  if __name__ == "__main__":
173
188
  asyncio.run(main())
174
189
  ```
175
190
 
176
- ### Creating a Service with Request Handler
191
+ ### Creating a Service for Request-Response
177
192
 
178
193
  ```python
179
194
  import asyncio
180
195
  import uuid
181
- from h_message_bus import NatsConfig, NatsSubscriberAdapter, NatsPublisherAdapter, HaiMessage, Topic
182
-
183
- async def request_handler(request: HaiMessage):
184
- print(f"Received request: {request.message_id}")
185
- print(f"Payload: {request.payload}")
186
-
187
- # Process the request
188
- result = {"status": "success", "data": {"result": 42}}
189
-
190
- # Create a response message
191
- return HaiMessage(
192
- message_id=str(uuid.uuid4()),
193
- sender="service-b",
194
- topic=f"{request.topic}.response",
195
- payload=result,
196
- correlation_id=request.message_id
197
- )
196
+ import json
197
+ from h_message_bus import NatsConfig, NatsSubscriberAdapter, NatsPublisherAdapter, HaiMessage, NatsClientRepository, MessageProcessor
198
+
199
+ class RequestResponseProcessor(MessageProcessor):
200
+ def __init__(self, publisher):
201
+ self.publisher = publisher
202
+
203
+ async def process(self, request: HaiMessage):
204
+ print(f"Received request: {request.id}")
205
+ print(f"Payload: {request.payload}")
206
+
207
+ # Process the request
208
+ result = {"status": "success", "data": {"result": 42}}
209
+
210
+ # Create a response message
211
+ response = HaiMessage(
212
+ id=str(uuid.uuid4()),
213
+ topic=f"{request.topic}.response",
214
+ payload=result
215
+ )
216
+
217
+ # Publish the response
218
+ await self.publisher.publish(response)
198
219
 
199
220
  async def main():
200
221
  # Configure NATS connection
201
222
  config = NatsConfig(server="nats://localhost:4222")
202
-
203
- # Create subscriber for handling requests
204
- subscriber = NatsSubscriberAdapter(config)
205
- publisher = NatsPublisherAdapter(config)
206
-
223
+
224
+ # Create NATS client repository
225
+ client_repository = NatsClientRepository(config)
226
+
207
227
  # Connect to NATS
208
- await subscriber.connect()
209
- await publisher.connect()
210
-
211
- # Register request handler for vector database queries
212
- await subscriber.subscribe_with_response(Topic.AI_VECTORS_QUERY, request_handler, publisher)
213
-
228
+ await client_repository.connect()
229
+
230
+ # Create publisher and subscriber
231
+ publisher = NatsPublisherAdapter(client_repository)
232
+ subscriber = NatsSubscriberAdapter(client_repository)
233
+
234
+ # Create request processor that uses the publisher
235
+ processor = RequestResponseProcessor(publisher)
236
+
237
+ # Subscribe to the request topic
238
+ await subscriber.subscribe("hai.ai.vectors.query", processor)
239
+
214
240
  # Keep the application running
215
241
  try:
216
242
  print("Service running. Press Ctrl+C to exit.")
@@ -218,8 +244,7 @@ async def main():
218
244
  await asyncio.sleep(1)
219
245
  except KeyboardInterrupt:
220
246
  # Clean up
221
- await subscriber.close()
222
- await publisher.close()
247
+ await client_repository.close()
223
248
 
224
249
  if __name__ == "__main__":
225
250
  asyncio.run(main())
@@ -237,7 +262,6 @@ The `NatsConfig` class allows you to customize your NATS connection:
237
262
  | `connection_timeout` | Connection timeout (seconds) | 2 |
238
263
  | `ping_interval` | Interval for ping frames (seconds) | 20 |
239
264
  | `max_outstanding_pings` | Maximum unanswered pings before disconnect | 5 |
240
- | `max_payload` | Maximum size of the payload in bytes | 1048576 (1MB) |
241
265
 
242
266
  ## API Reference
243
267
 
@@ -251,7 +275,6 @@ The following classes are exported directly from the package:
251
275
  - `NatsSubscriberAdapter` - Adapter for subscribing to messages
252
276
  - `MessageProcessor` - Processing incoming messages
253
277
  - `NatsClientRepository` - Low-level NATS client operations
254
- - `Topic` - Enumeration of predefined topic strings
255
278
 
256
279
  ### HaiMessage Structure
257
280
 
@@ -259,12 +282,10 @@ The `HaiMessage` class is the core data structure used for all messaging:
259
282
 
260
283
  ```python
261
284
  class HaiMessage:
262
- message_id: str # Unique identifier for the message
263
- sender: str # Identifier of the sender
285
+ id: str # Unique identifier for the message
264
286
  topic: str # The topic or channel for the message
265
287
  payload: dict # Actual message data
266
- correlation_id: str = None # Optional reference to a related message
267
- timestamp: float = None # Optional message creation timestamp
288
+ timestamp: str = None # Optional message creation timestamp (ISO format)
268
289
  ```
269
290
 
270
291
  ## Contributing
@@ -0,0 +1,20 @@
1
+ __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ h_message_bus/__init__.py,sha256=T_07sHtXLlRuLwK-BRVfFIIOGc48TKbtVLvKtIw2K5U,516
3
+ h_message_bus/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ h_message_bus/adapters/nats_message_adapter.py,sha256=-hzx0UJmKJT4VWfRA_zVT68hddl9dejvUiSdLU1rY-w,1378
5
+ h_message_bus/adapters/nats_publisher_adapter.py,sha256=EgrGioGuZfLpJsb5wiialMGMe8E4oUktS8zMdGri3Lc,1982
6
+ h_message_bus/adapters/nats_subscriber_adapter.py,sha256=UJN2Es7hokbO5YsSUAf0KQ2B15QcGzGtQx-G1S3iQWQ,2105
7
+ h_message_bus/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ h_message_bus/application/message_processor.py,sha256=1vdVfPn1BUDmswJ-Y5aS-YDbLSizrjX6_CMIBa5SGjc,734
9
+ h_message_bus/application/message_publisher.py,sha256=pYX4JzJLe7L_59gKVYBLqT6iTwFB73zhbzxd7yv2TqI,834
10
+ h_message_bus/application/message_subcriber.py,sha256=2yqUUHVHtZlA6-zzyHzghdWQ7ZmdcFic5c0xi_rgG-M,741
11
+ h_message_bus/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ h_message_bus/domain/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ h_message_bus/domain/models/hai_message.py,sha256=b5CfX7hi5uNq77IVnZzEi9iotc4b_U2MNYwV6JY7JcU,2146
14
+ h_message_bus/infrastructure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ h_message_bus/infrastructure/nats_client_repository.py,sha256=aAwtUhDZAWOF8fF4IPfcUH5Gc6UscO41ST7rh-HsN2A,4505
16
+ h_message_bus/infrastructure/nats_config.py,sha256=xg-Ak6H92T32DZKCsbWYQMO9J8nUBI0JZcUY3aA5w1c,1308
17
+ h_message_bus-0.0.41.dist-info/METADATA,sha256=gVKKEx7HpSIfCGt9omofxOpUqJx077emtCAG0HT2FO0,9171
18
+ h_message_bus-0.0.41.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ h_message_bus-0.0.41.dist-info/top_level.txt,sha256=BArjhm_lwFR9yJJEIf-LT_X64psuLkXFdbpQRJUreFE,23
20
+ h_message_bus-0.0.41.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes
@@ -1,20 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class EventMessageTopic(str, Enum):
5
- """
6
- Represents a collection of predefined topics as an enumeration.
7
-
8
- This class is an enumeration that defines constant string values for use
9
- as topic identifiers. These topics represent specific actions or messages
10
- within a messaging or vector database management context. It ensures
11
- consistent usage of these predefined topics across the application.
12
-
13
- syntax: [hai].[source].[destination].[action]
14
-
15
- """
16
- # Events
17
- STARTUP = "hai.startup"
18
- SHUTDOWN = "hai.shutdown"
19
- ENTITY_OFFICIAL_UPDATE = "hai.entity.official.update"
20
- VECTOR_STALE_INFORMATION = "hai.vector.collection.stale.information"
@@ -1,100 +0,0 @@
1
- from enum import Enum
2
-
3
-
4
- class RequestMessageTopic(str, Enum):
5
- """
6
- Represents a collection of predefined topics as an enumeration.
7
-
8
- This class is an enumeration that defines constant string values for use
9
- as topic identifiers. These topics represent specific actions or messages
10
- within a messaging or vector database management context. It ensures
11
- consistent usage of these predefined topics across the application.
12
-
13
- syntax: [hai].[source].[destination].[action]
14
-
15
- """
16
- # Telegram
17
- TG_CHAT_SEND = "hai.tg.chat.send"
18
- TG_USER_CHAT_SEND = "hai.tg.user.chat.send"
19
- TG_CHAT_REPLY = "hai.tg.chat.reply"
20
-
21
- # vector database
22
- VECTORS_SAVE = "hai.vectors.save"
23
-
24
- VECTORS_QUERY = "hai.vectors.query"
25
- VECTORS_QUERY_RESPONSE = "hai.vectors.query.response"
26
-
27
- VECTORS_METADATA_READ = "hai.vectors.metadata.read"
28
- VECTORS_METADATA_READ_RESPONSE = "hai.vectors.metadata.read.response"
29
-
30
- # Twitter
31
- TWITTER_GET_USER = "hai.twitter.get.user"
32
- TWITTER_GET_USER_RESPONSE = "hai.twitter.get.user.response"
33
- TWITTER_GET_USERS = "hai.twitter.get.users"
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"
37
-
38
- TWITTER_USER_SEND_AI_CHAT_SEND = "hai.twitter.user.chat.send"
39
- TWITTER_USER_SEND_AI_CHAT_SEND_RESPONSE = "hai.twitter.user.chat.send.response"
40
-
41
- TWITTER_FOLLOW_USER= "hai.twitter.follow.user"
42
- TWITTER_FOLLOW_USER_RESPONSE = "hai.twitter.follow.user.response"
43
-
44
- TWITTER_GET_HOME_TIMELINE= "hai.twitter.get.home.timeline"
45
- TWITTER_GET_HOME_TIMELINE_RESPONSE = "hai.twitter.get.home.timeline.response"
46
-
47
- TWITTER_RETWEET= "hai.twitter.retweet"
48
- TWITTER_RETWEET_RESPONSE = "hai.twitter.retweet.response"
49
-
50
- TWITTER_REPLY= "hai.twitter.reply"
51
- TWITTER_REPLY_RESPONSE = "hai.twitter.reply.response"
52
-
53
- TWITTER_POST_TWEET= "hai.twitter.post.tweet"
54
- TWITTER_POST_TWEET_RESPONSE = "hai.twitter.post.tweet.response"
55
-
56
- TWITTER_QUOTE_RETWEET= "hai.twitter.quote.retweet"
57
- TWITTER_QUOTE_RETWEET_RESPONSE = "hai.twitter.quote.retweet.response"
58
-
59
- TWITTER_GET_TWEET= "hai.twitter.get.tweet"
60
- TWITTER_GET_TWEET_RESPONSE = "hai.twitter.get.tweet.response"
61
-
62
- TWITTER_SEARCH= "hai.twitter.search"
63
- TWITTER_SEARCH_RESPONSE = "hai.twitter.search.response"
64
-
65
- # tools
66
- WEB_SEARCH = "hai.tools.web.search"
67
- WEB_SEARCH_RESPONSE = "hai.tools.web.search.response"
68
-
69
- WEB_GET_DOCS = "hai.tools.web.get.docs"
70
- WEB_GET_DOCS_RESPONSE = "hai.tools.web.get.docs.response"
71
-
72
- WEB_FIND_RELATED = "hai.tools.web.find.related"
73
- WEB_FIND_RELATED_RESPONSE = "hai.tools.web.find.related.response"
74
-
75
- INIT_KNOWLEDGE_BASE = "hai.tools.init.knowledge.base"
76
- INIT_KNOWLEDGE_BASE_RESPONSE = "hai.tools.init.knowledge.base.response"
77
-
78
- # graph database
79
- GRAPH_NODE_ADD = "hai.graph.node.add"
80
- GRAPH_NODE_UPDATE = "hai.graph.node.update"
81
- GRAPH_NODE_GET = "hai.graph.node.get"
82
- GRAPH_NODE_DELETE = "hai.graph.node.delete"
83
- GRAPH_RELATIONSHIP_ADD = "hai.graph.relationship.add"
84
- GRAPH_RELATIONSHIP_DELETE = "hai.graph.relationship.delete"
85
- GRAPH_QUERY = "hai.graph.query"
86
- GRAPH_CLEAR = "hai.graph.clear"
87
- GRAPH_GET_ALL = "hai.graph.get.all"
88
- GRAPH_NODES_BY_PROPERTY = "hai.graph.nodes.by.property"
89
-
90
- GRAPH_QUERY_OPERATION = "hai.graph.query.operation"
91
- GRAPH_QUERY_OPERATION_RESPONSE = "hai.graph.query.operation.response"
92
-
93
- GRAPH_NODE_ADD_RESPONSE = "hai.graph.node.add.response"
94
- GRAPH_NODE_UPDATE_RESPONSE = "hai.graph.node.update.response"
95
- GRAPH_NODE_GET_RESPONSE = "hai.graph.node.get.response"
96
- GRAPH_RELATIONSHIP_ADD_RESPONSE = "hai.graph.relationship.add.response"
97
- GRAPH_QUERY_RESPONSE = "hai.graph.query.response"
98
- GRAPH_CLEAR_RESPONSE = "hai.graph.clear.response"
99
- GRAPH_GET_ALL_RESPONSE = "hai.graph.get.all.response"
100
- GRAPH_NODES_BY_PROPERTY_RESPONSE = "hai.graph.nodes.by.property.response"
@@ -1,31 +0,0 @@
1
- from ...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
- }
@@ -1,76 +0,0 @@
1
- class TwitterUserMetadata:
2
- def __init__(self,
3
- id: str,
4
- screen_name: str,
5
- user_name: str = None,
6
- description: str = None,
7
- followers_count: int = 0,
8
- like_count: int = 0,
9
- is_verified: bool = False,
10
- url: str = None,
11
- bio_urls: list = None):
12
- """
13
- Initialize a TwitterUserMetadata instance.
14
-
15
- Args:
16
- id (str): The user's Twitter ID
17
- screen_name (str): The user's screen name
18
- user_name (str, optional): The user's name
19
- description (str, optional): The user's bio description
20
- followers_count (int, optional): Number of followers
21
- like_count (int, optional): Number of likes
22
- is_verified (bool, optional): Whether the user is verified
23
- url (str, optional): The user's profile URL
24
- bio_urls (list, optional): URLs mentioned in the user's bio
25
- """
26
- self.id = id
27
- self.screen_name = screen_name
28
- self.user_name = user_name
29
- self.description = description
30
- self.followers_count = followers_count
31
- self.like_count = like_count
32
- self.is_verified = is_verified
33
- self.url = url
34
- self.bio_urls = bio_urls or []
35
-
36
- def to_dict(self) -> dict:
37
- """
38
- Convert TwitterUserMetadata instance to a dictionary.
39
-
40
- Returns:
41
- dict: A dictionary representation of the TwitterUserMetadata instance.
42
- """
43
- return {
44
- 'id': self.id,
45
- 'screen_name': self.screen_name,
46
- 'user_name': self.user_name,
47
- 'description': self.description,
48
- 'followers_count': self.followers_count,
49
- 'like_count': self.like_count,
50
- 'is_verified': self.is_verified,
51
- 'url': self.url,
52
- 'bio_urls': self.bio_urls
53
- }
54
-
55
- @classmethod
56
- def from_dict(cls, data: dict) -> 'TwitterUserMetadata':
57
- """
58
- Create a TwitterUserMetadata instance from a dictionary.
59
-
60
- Args:
61
- data (dict): A dictionary containing TwitterUserMetadata attributes
62
-
63
- Returns:
64
- TwitterUserMetadata: A new TwitterUserMetadata instance
65
- """
66
- return cls(
67
- id=data.get('id'),
68
- screen_name=data.get('screen_name'),
69
- user_name=data.get('user_name'),
70
- description=data.get('description'),
71
- followers_count=data.get('followers_count', 0),
72
- like_count=data.get('like_count', 0),
73
- is_verified=data.get('is_verified', False),
74
- url=data.get('url'),
75
- bio_urls=data.get('bio_urls', [])
76
- )
@@ -1,30 +0,0 @@
1
- from dataclasses import dataclass
2
-
3
-
4
- @dataclass
5
- class VectorCollectionMetadata:
6
- collection_name: str
7
- last_updated: str
8
- last_queried: str
9
- query_count: int = 0
10
-
11
- @classmethod
12
- def from_dict(cls, data: dict) -> 'VectorCollectionMetadata':
13
- """Create an instance from a dictionary."""
14
- return cls(
15
- collection_name=data.get('collection_name', ''),
16
- last_updated=data.get('last_updated', ''),
17
- last_queried=data.get('last_queried', ''),
18
- query_count=data.get('query_count', 0)
19
- )
20
-
21
- def to_dict(self) -> dict:
22
- """Convert instance to a dictionary."""
23
- return {
24
- 'collection_name': self.collection_name,
25
- 'last_updated': self.last_updated,
26
- 'last_queried': self.last_queried,
27
- 'query_count': self.query_count
28
- }
29
-
30
-
@@ -1,22 +0,0 @@
1
- from dataclasses import dataclass
2
-
3
-
4
- @dataclass
5
- class VectorQueryAnswer:
6
- text: str
7
- dimension: str
8
-
9
- @classmethod
10
- def from_dict(cls, data: dict) -> 'VectorQueryAnswer':
11
- """Create an instance from a dictionary."""
12
- return cls(
13
- text=data.get('text', ''),
14
- dimension=data.get('dimension', ''),
15
- )
16
-
17
- def to_dict(self) -> dict:
18
- """Convert instance to a dictionary."""
19
- return {
20
- 'text': self.text,
21
- 'dimension': self.dimension,
22
- }
File without changes