Skip to content

Commit 88b9507

Browse files
revert
Signed-off-by: Adrian Cole <[email protected]>
1 parent 75a91cc commit 88b9507

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

examples/helloworld/test_client.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from a2a.client import A2AClient
2+
from typing import Any
3+
import httpx
4+
from uuid import uuid4
5+
from a2a.types import (
6+
SendMessageRequest,
7+
MessageSendParams,
8+
SendStreamingMessageRequest,
9+
)
10+
11+
12+
async def main() -> None:
13+
async with httpx.AsyncClient() as httpx_client:
14+
client = await A2AClient.get_client_from_agent_card_url(
15+
httpx_client, 'http://localhost:9999'
16+
)
17+
send_message_payload: dict[str, Any] = {
18+
'message': {
19+
'role': 'user',
20+
'parts': [
21+
{'type': 'text', 'text': 'how much is 10 USD in INR?'}
22+
],
23+
'messageId': uuid4().hex,
24+
},
25+
}
26+
request = SendMessageRequest(
27+
params=MessageSendParams(**send_message_payload)
28+
)
29+
30+
response = await client.send_message(request)
31+
print(response.model_dump(mode='json', exclude_none=True))
32+
33+
streaming_request = SendStreamingMessageRequest(
34+
params=MessageSendParams(**send_message_payload)
35+
)
36+
37+
stream_response = client.send_message_streaming(streaming_request)
38+
async for chunk in stream_response:
39+
print(chunk.model_dump(mode='json', exclude_none=True))
40+
41+
42+
if __name__ == '__main__':
43+
import asyncio
44+
45+
asyncio.run(main())

0 commit comments

Comments
 (0)