Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ composable integration value:
| `streamfold/langchain` | `langchain` |
| `streamfold/ag-ui` | `agUI` |

The OpenAI integration accepts `client.responses.create({ ..., stream: true })`
directly, including SDK event interfaces for text and other non-tool events.
Non-tool events are ignored; callers do not need to cast or filter the stream.

| Method | Returns |
| --- | --- |
| `pushAll(event)` | All lifecycle updates caused by this event, in order; `[]` for ignored events |
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Accept OpenAI SDK response stream event types directly in the OpenAI adapter
and managed reader, including non-tool events.
- Preserve Gemini Interactions tool arguments from `arguments_delta` events
without treating the initial empty object as the completed input.
- Reuse the final frozen snapshot in immutable pool completions, avoiding a
Expand Down
2 changes: 1 addition & 1 deletion examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"checkJs": true,
"skipLibCheck": true
},
"files": ["assistant-ui.mjs", "vercel-ai.mjs", "custom.mjs", "../tests/langchain-sdk.ts", "../tests/gemini-sdk.ts"]
"files": ["assistant-ui.mjs", "vercel-ai.mjs", "custom.mjs", "../tests/langchain-sdk.ts", "../tests/gemini-sdk.ts", "../tests/openai-sdk.ts"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"assistant-stream": "0.3.42",
"bumpp": "^12.3.0",
"fast-check": "4.10.2",
"openai": "7.45.1",
"playwright": "^1.63.0",
"streamfold": "workspace:*",
"typescript": "^7.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/openai.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type OpenAiResponsesToolEvent =
readonly item_id: string;
readonly arguments: string;
}
| { readonly type: string }
| {
readonly type: string;
readonly [key: string]: unknown;
Expand Down
46 changes: 42 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/openai-sdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import OpenAI from "openai";
import type { ResponseStreamEvent } from "openai/resources/responses/responses";
import { readStructured } from "streamfold";
import { openAI } from "streamfold/openai";

const client = new OpenAI({ apiKey: "typecheck-only" });
const events = await client.responses.create({
model: "fixture", input: "Weather in Paris?", stream: true,
});
readStructured(events, { integration: openAI });
const stream = openAI();
for await (const event of events) stream.pushAll(event);

declare const event: ResponseStreamEvent;
stream.push(event);
stream.pushAll({ type: "response.future_event", metadata: { source: "provider" } });
Loading