-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_server.py
More file actions
38 lines (33 loc) · 1.14 KB
/
Copy pathtest_server.py
File metadata and controls
38 lines (33 loc) · 1.14 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
38
import asyncio
import json
import httpx
async def main():
async with httpx.AsyncClient() as client:
# Create a new session
try:
response = await client.post("http://127.0.0.1:8000/apps/app/users/user/sessions", json={})
session_id = response.json().get("session_id")
except httpx.ConnectError:
print("Failed to connect to 8000. Start the server first.")
return
print("Session ID:", session_id)
# Send an event
payload = {
"session_id": session_id,
"inputs": {"animal": "elephant", "location": "sector 9"},
"user_id": "user",
"app_name": "app"
}
# Using the standard /run_sse endpoint ADK UI uses
print("Sending run_sse...")
response = await client.post(
"http://127.0.0.1:8000/run_sse",
json=payload,
timeout=10.0
)
print("Response:", response.status_code)
print("Text:")
for line in response.text.split("\n"):
print(line)
if __name__ == "__main__":
asyncio.run(main())