Skip to content

Commit 75f8425

Browse files
whoiskatrinthreepointone
authored andcommitted
refactor AIHttpChatAgent to utilize a new ResumableStreamManager
1 parent 512bd42 commit 75f8425

File tree

5 files changed

+747
-538
lines changed

5 files changed

+747
-538
lines changed

examples/resumable-stream-chat/src/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ type Env = {
1616

1717
export class ResumableChatAgent extends AIHttpChatAgent<Env> {
1818
async onChatMessage(
19-
onFinish: StreamTextOnFinishCallback<ToolSet>
19+
onFinish: StreamTextOnFinishCallback<ToolSet>,
20+
_options?: { streamId?: string }
2021
): Promise<Response | undefined> {
2122
const stream = createUIMessageStream({
2223
execute: async ({ writer }) => {
@@ -30,7 +31,8 @@ export class ResumableChatAgent extends AIHttpChatAgent<Env> {
3031
}
3132
});
3233

33-
return createUIMessageStreamResponse({ stream });
34+
const response = createUIMessageStreamResponse({ stream });
35+
return response;
3436
}
3537
}
3638

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "resumable-chat",
3+
"main": "./src/server.ts",
4+
"compatibility_date": "2025-02-21",
5+
"compatibility_flags": [
6+
"nodejs_compat",
7+
"nodejs_compat_populate_process_env"
8+
],
9+
"assets": {
10+
"directory": "public"
11+
},
12+
"durable_objects": {
13+
"bindings": [
14+
{
15+
"name": "ResumableChatAgent",
16+
"class_name": "ResumableChatAgent"
17+
}
18+
]
19+
},
20+
"migrations": [
21+
{
22+
"tag": "v1",
23+
"new_sqlite_classes": ["ResumableChatAgent"]
24+
}
25+
]
26+
}

examples/resumable-stream-chat/wrangler.toml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)