Skip to content

Commit e27ba1f

Browse files
jhammarstedtmaxkorp
authored andcommitted
cleanup
1 parent ee2e349 commit e27ba1f

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

docs/quickstart/server.mdx

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Open `apps/dojo/package.json` and add the package `@ag-ui/openai-server`:
163163
"@ag-ui/server-starter": "workspace:*",
164164
"@ag-ui/server-starter-all-features": "workspace:*",
165165
"@ag-ui/vercel-ai-sdk": "workspace:*",
166-
"@ag-ui/openai-server": "workspace:*", <- Add this line
166+
"@ag-ui/openai-server": "workspace:*", // Add this line
167167

168168
... rest of package.json
169169
}
@@ -390,6 +390,8 @@ from ag_ui.core import (
390390
RunStartedEvent,
391391
RunFinishedEvent,
392392
RunErrorEvent,
393+
TextMessageChunkEvent,
394+
ToolCallChunkEvent,
393395
)
394396
from ag_ui.encoder import EventEncoder
395397
from openai import OpenAI
@@ -451,22 +453,26 @@ async def agentic_chat_endpoint(input_data: RunAgentInput, request: Request):
451453
for chunk in stream:
452454
# Handle text content chunks
453455
if chunk.choices[0].delta.content:
454-
yield encoder.encode({
455-
"type": EventType.TEXT_MESSAGE_CHUNK,
456-
"message_id": message_id,
457-
"delta": chunk.choices[0].delta.content,
458-
})
456+
yield encoder.encode(
457+
TextMessageChunkEvent(
458+
type=EventType.TEXT_MESSAGE_CHUNK,
459+
message_id=message_id,
460+
delta=chunk.choices[0].delta.content,
461+
)
462+
)
459463
# Handle tool call chunks
460464
elif chunk.choices[0].delta.tool_calls:
461465
tool_call = chunk.choices[0].delta.tool_calls[0]
462466

463-
yield encoder.encode({
464-
"type": EventType.TOOL_CALL_CHUNK,
465-
"tool_call_id": tool_call.id,
466-
"tool_call_name": tool_call.function.name if tool_call.function else None,
467-
"parent_message_id": message_id,
468-
"delta": tool_call.function.arguments if tool_call.function else None,
469-
})
467+
yield encoder.encode(
468+
ToolCallChunkEvent(
469+
type=EventType.TOOL_CALL_CHUNK,
470+
tool_call_id=tool_call.id,
471+
tool_call_name=tool_call.function.name if tool_call.function else None,
472+
parent_message_id=message_id,
473+
delta=tool_call.function.arguments if tool_call.function else None,
474+
)
475+
)
470476

471477
yield encoder.encode(
472478
RunFinishedEvent(
@@ -516,7 +522,7 @@ Let's break down what your server is doing:
516522

517523
Test your endpoint with:
518524
```bash
519-
curl -X POST http://localhost:8000/awp \
525+
curl -X POST http://localhost:8000/awp \
520526
-H "Content-Type: application/json" \
521527
-H "Accept: text/event-stream" \
522528
-d '{

0 commit comments

Comments
 (0)