forked from nicknochnack/ACPWalkthrough
-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy patha2a_healthcare_client.py
More file actions
37 lines (26 loc) · 1.08 KB
/
a2a_healthcare_client.py
File metadata and controls
37 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import asyncio
import os
from typing import Any
from beeai_framework.adapters.a2a.agents import A2AAgent
from beeai_framework.memory import UnconstrainedMemory
from beeai_framework.middleware.trajectory import EventMeta, GlobalTrajectoryMiddleware
from helpers import setup_env
class ConciseGlobalTrajectoryMiddleware(GlobalTrajectoryMiddleware):
def _format_prefix(self, meta: EventMeta) -> str:
prefix = super()._format_prefix(meta)
return prefix.rstrip(": ")
def _format_payload(self, value: Any) -> str:
return ""
async def main() -> None:
setup_env()
host = os.getenv("AGENT_HOST")
healthcare_agent_port = int(os.getenv("HEALTHCARE_AGENT_PORT"))
agent = A2AAgent(
url=f"http://{host}:{healthcare_agent_port}", memory=UnconstrainedMemory()
)
response = await agent.run(
"I'm based in Austin, TX. How do I get mental health therapy near me and what does my insurance cover?"
).middleware(ConciseGlobalTrajectoryMiddleware())
print(response.last_message.text)
if __name__ == "__main__":
asyncio.run(main())