vital-agent-container-sdk 0.1.1__py3-none-any.whl → 0.1.2__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.
@@ -42,11 +42,13 @@ class AgentContainerApp(FastAPI):
42
42
  self.app_home = app_home
43
43
  load_dotenv()
44
44
  self.config = ConfigUtils.load_config(app_home)
45
+ self.message_processor = AIMPMessageProcessor()
45
46
  self.add_routes()
46
47
 
47
48
  async def process_ws_message(self, client: httpx.AsyncClient, websocket: WebSocket, data: str,
48
49
  started_event: asyncio.Event):
49
- await AIMPMessageProcessor.process_message(self.handler, self.config, client, websocket, data, started_event)
50
+ print(f"process_ws_message: Processing: {data}")
51
+ await self.message_processor.process_message(self.handler, self.config, client, websocket, data, started_event)
50
52
 
51
53
  def add_routes(self):
52
54
  @self.get("/health")
@@ -67,8 +69,9 @@ class AgentContainerApp(FastAPI):
67
69
 
68
70
  logger.info(f"Received message from {websocket.client.host}:{websocket.client.port}: {data}")
69
71
  message_obj = json.loads(data)
70
- message_type = message_obj[0].get("type")
71
- message_intent = message_obj[0].get("http://vital.ai/ontology/vital-aimp#hasIntent")
72
+ logger.info(f"Received message: {message_obj}")
73
+ message_type = message_obj[0].get("type", None)
74
+ message_intent = message_obj[0].get("http://vital.ai/ontology/vital-aimp#hasIntent", None)
72
75
  logger.info(f"message_type: {message_type}")
73
76
  logger.info(f"message_intent: {message_intent}")
74
77
 
@@ -96,9 +99,12 @@ class AgentContainerApp(FastAPI):
96
99
  else:
97
100
  logger.info(f"Processing message: {data}")
98
101
  started_event = asyncio.Event()
99
- task = asyncio.create_task(self.process_ws_message(self.handler, client, websocket, data, started_event))
102
+ task = asyncio.create_task(self.process_ws_message(client, websocket, data, started_event))
100
103
  background_tasks.append(task)
101
104
  await started_event.wait()
105
+ logger.info(f"Completed Processing message: {data}")
106
+ # break out of infinite loop
107
+ break
102
108
  except WebSocketDisconnect:
103
109
  logger.info("WebSocket connection closed by the client.")
104
110
  # still try to close it in finally?
@@ -1,5 +1,14 @@
1
+ import asyncio
2
+ import httpx
3
+ from starlette.websockets import WebSocket
4
+ from abc import ABC, abstractmethod
5
+
6
+
7
+ class AIMPMessageHandlerInf(ABC):
8
+
9
+ @abstractmethod
10
+ async def process_message(self, config, client: httpx.AsyncClient, websocket: WebSocket, data: str, started_event: asyncio.Event):
11
+ pass
1
12
 
2
13
 
3
- class AIMPMessageHandlerInf:
4
- pass
5
14
 
@@ -1,7 +1,23 @@
1
+ import asyncio
2
+ import httpx
3
+ from starlette.websockets import WebSocket
1
4
  from vital_agent_container.handler.aimp_message_handler_inf import AIMPMessageHandlerInf
2
5
 
3
6
 
4
7
  class AIMPEchoMessageHandler(AIMPMessageHandlerInf):
5
- pass
8
+ async def process_message(self, config, client: httpx.AsyncClient, websocket: WebSocket, data: str, started_event: asyncio.Event):
9
+ try:
10
+ print(f"Received Message: {data}")
11
+ await websocket.send_text(data)
12
+ print(f"Sent Message: {data}")
13
+ # await websocket.close(1000, "Processing Complete")
14
+ # print(f"Websocket closed.")
15
+ started_event.set()
16
+ print(f"Completed Event.")
17
+ except asyncio.CancelledError:
18
+ # log canceling
19
+ raise
20
+
21
+
6
22
 
7
23
 
@@ -1,3 +1,6 @@
1
+ import asyncio
2
+
3
+ from vital_agent_container.handler.aimp_message_handler_inf import AIMPMessageHandlerInf
1
4
 
2
5
 
3
6
  class AIMPMessageProcessor:
@@ -5,5 +8,11 @@ class AIMPMessageProcessor:
5
8
  def __init__(self):
6
9
  pass
7
10
 
8
- async def process_message(self, handler, app_config, client, websocket, data, started_event):
9
- pass
11
+ async def process_message(self, handler: AIMPMessageHandlerInf, app_config, client, websocket, data, started_event):
12
+ print(f"Processing: {data}")
13
+ try:
14
+ return await handler.process_message(app_config, client, websocket, data, started_event)
15
+ except asyncio.CancelledError:
16
+ # log canceling
17
+ raise
18
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vital-agent-container-sdk
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Vital Agent Container SDK
5
5
  Home-page: https://github.com/vital-ai/vital-agent-container-python
6
6
  Author: Marc Hadfield
@@ -12,8 +12,8 @@ Classifier: Operating System :: OS Independent
12
12
  Requires-Python: >=3.10
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
- Requires-Dist: vital-ai-vitalsigns ==0.1.19
16
- Requires-Dist: vital-ai-aimp ==0.1.6
15
+ Requires-Dist: vital-ai-vitalsigns ==0.1.20
16
+ Requires-Dist: vital-ai-aimp ==0.1.7
17
17
  Requires-Dist: httpx ==0.26.0
18
18
  Requires-Dist: python-json-logger ==2.0.7
19
19
  Requires-Dist: python-dotenv ==1.0.1
@@ -1,12 +1,12 @@
1
1
  vital_agent_container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- vital_agent_container/agent_container_app.py,sha256=H9b5dzW6FDZMdqb2oaf7Nqtj2GS2APdl5YslXAdZsJI,5538
2
+ vital_agent_container/agent_container_app.py,sha256=5lbge8OC8tEkjJ_TsZ9-zkRPPKA_Jr8gwwIFxmo7z6U,5879
3
3
  vital_agent_container/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  vital_agent_container/handler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- vital_agent_container/handler/aimp_message_handler_inf.py,sha256=p2Itiil2K1acZ6Js_rShL5mJyrciqH2B_pqwmPJp_zw,41
5
+ vital_agent_container/handler/aimp_message_handler_inf.py,sha256=H9Bey5fAAh13LscsmwlCkK6i-rMKe5iN_vwk279p57s,315
6
6
  vital_agent_container/handler/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- vital_agent_container/handler/impl/aimp_echo_message_handler.py,sha256=Rt4yE-_wlyIUdLhuBQ-dKQ7bycRDHCA6KgtphA4fgFA,155
7
+ vital_agent_container/handler/impl/aimp_echo_message_handler.py,sha256=QQl3MbAWONno408wXOXzlubhFRvp9Vjwk5iCiF12Sek,764
8
8
  vital_agent_container/processor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- vital_agent_container/processor/aimp_message_processor.py,sha256=KcyzRQNhEuPM8PCg7Oq0GycIjAfVPoPLvjlYzd2CYR8,180
9
+ vital_agent_container/processor/aimp_message_processor.py,sha256=4aaMEKxpzpXuH-kjLyqGY8t5PkqFif7Dr5ZaFHKEr2o,532
10
10
  vital_agent_container/streaming/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  vital_agent_container/streaming/custom_streaming_response.py,sha256=KDuhl4Z5opb0pxCymkjFvyBPKvhf64TZatLY-qK0l_w,1059
12
12
  vital_agent_container/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -15,8 +15,8 @@ vital_agent_container/tasks/task_manager_async_client.py,sha256=hOkhGYgtdrpOkZyg
15
15
  vital_agent_container/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  vital_agent_container/utils/aws_utils.py,sha256=HuwdOs58VU9UDnytx2QlKjJNoPE9k2KIQbKJwgi-9zk,580
17
17
  vital_agent_container/utils/config_utils.py,sha256=0iqBXct1O0nMTTBkYSdqIp0WIuVM24fbSpw5uoZQi8k,426
18
- vital_agent_container_sdk-0.1.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
19
- vital_agent_container_sdk-0.1.1.dist-info/METADATA,sha256=Obf9jQzG8K0CKLcVr9bg4ayWF114Xi1rOP8aWj-rdW0,1187
20
- vital_agent_container_sdk-0.1.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
21
- vital_agent_container_sdk-0.1.1.dist-info/top_level.txt,sha256=acZrRgjFIj0mWxdLPWONKwMgxnFReQmyjttb8Z76fsc,22
22
- vital_agent_container_sdk-0.1.1.dist-info/RECORD,,
18
+ vital_agent_container_sdk-0.1.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
19
+ vital_agent_container_sdk-0.1.2.dist-info/METADATA,sha256=UqRcZ3v3Q_jkm_2luMEthBtiSGKzeKVDR265f9uSgrY,1187
20
+ vital_agent_container_sdk-0.1.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
21
+ vital_agent_container_sdk-0.1.2.dist-info/top_level.txt,sha256=acZrRgjFIj0mWxdLPWONKwMgxnFReQmyjttb8Z76fsc,22
22
+ vital_agent_container_sdk-0.1.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5