Skip to content

Commit 32bd884

Browse files
authored
Python: Add concrete AGUIChatClient (#2072)
* Add concrete AGUIChatClient * Update logging docstrings and conventions * PR feedback * Updates to support client-side tool calls
1 parent 93ab43d commit 32bd884

26 files changed

+6469
-4096
lines changed

python/packages/ag-ui/README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pip install agent-framework-ag-ui
1010

1111
## Quick Start
1212

13+
### Server (Host an AI Agent)
14+
1315
```python
1416
from fastapi import FastAPI
1517
from agent_framework import ChatAgent
@@ -23,6 +25,7 @@ agent = ChatAgent(
2325
chat_client=AzureOpenAIChatClient(
2426
endpoint="https://your-resource.openai.azure.com/",
2527
deployment_name="gpt-4o-mini",
28+
api_key="your-api-key",
2629
),
2730
)
2831

@@ -33,9 +36,38 @@ add_agent_framework_fastapi_endpoint(app, agent, "/")
3336
# Run with: uvicorn main:app --reload
3437
```
3538

39+
### Client (Connect to an AG-UI Server)
40+
41+
```python
42+
import asyncio
43+
from agent_framework import TextContent
44+
from agent_framework_ag_ui import AGUIChatClient
45+
46+
async def main():
47+
async with AGUIChatClient(endpoint="http://localhost:8000/") as client:
48+
# Stream responses
49+
async for update in client.get_streaming_response("Hello!"):
50+
for content in update.contents:
51+
if isinstance(content, TextContent):
52+
print(content.text, end="", flush=True)
53+
print()
54+
55+
asyncio.run(main())
56+
```
57+
58+
The `AGUIChatClient` supports:
59+
- Streaming and non-streaming responses
60+
- Hybrid tool execution (client-side + server-side tools)
61+
- Automatic thread management for conversation continuity
62+
- Integration with `ChatAgent` for client-side history management
63+
3664
## Documentation
3765

38-
- **[Getting Started Tutorial](getting_started/)** - Step-by-step guide to building your first AG-UI server and client
66+
- **[Getting Started Tutorial](getting_started/)** - Step-by-step guide to building AG-UI servers and clients
67+
- Server setup with FastAPI
68+
- Client examples using `AGUIChatClient`
69+
- Hybrid tool execution (client-side + server-side)
70+
- Thread management and conversation continuity
3971
- **[Examples](agent_framework_ag_ui_examples/)** - Complete examples for AG-UI features
4072

4173
## Features

python/packages/ag-ui/agent_framework_ag_ui/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import importlib.metadata
66

77
from ._agent import AgentFrameworkAgent
8+
from ._client import AGUIChatClient
89
from ._confirmation_strategies import (
910
ConfirmationStrategy,
1011
DefaultConfirmationStrategy,
@@ -13,6 +14,8 @@
1314
TaskPlannerConfirmationStrategy,
1415
)
1516
from ._endpoint import add_agent_framework_fastapi_endpoint
17+
from ._event_converters import AGUIEventConverter
18+
from ._http_service import AGUIHttpService
1619

1720
try:
1821
__version__ = importlib.metadata.version(__name__)
@@ -22,6 +25,9 @@
2225
__all__ = [
2326
"AgentFrameworkAgent",
2427
"add_agent_framework_fastapi_endpoint",
28+
"AGUIChatClient",
29+
"AGUIEventConverter",
30+
"AGUIHttpService",
2531
"ConfirmationStrategy",
2632
"DefaultConfirmationStrategy",
2733
"TaskPlannerConfirmationStrategy",

0 commit comments

Comments
 (0)