-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat(provider/openai-compatible): OpenAI Compatible Response support #9723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
packages/openai-compatible/src/responses/openai-compatible-responses-language-model.ts
Outdated
Show resolved
Hide resolved
packages/openai-compatible/src/responses/openai-compatible-responses-language-model.ts
Outdated
Show resolved
Hide resolved
packages/openai-compatible/src/responses/openai-compatible-responses-language-model.ts
Outdated
Show resolved
Hide resolved
…ponses-language-model.ts Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
…eune/ai into feat/openai-compatible-response
…CompatibleProvider interface
|
I'm not sure whether some parts of the |
|
@DeJeune ideally it should be minimal to support the core set of what is available in the responses apis compatible providers. I think tests will be extremely critical. please adopt the fixture/snapshot model from openai responses and have fixtures for different providers. fixtures can be created as follows:
ideally we have fully realistic test input fixtures for various compatible providers, otherwise it will be hard to make this model stable and solid |
- Add test fixtures for basic text, reasoning, and tool call responses - Include both JSON and streaming chunk formats for comprehensive testing - Add snapshot tests for response parsing and streaming behavior - Fix provider metadata key in tool call responses
- add fixtures and snapshot
… compatible responses
| id: value.item.id, | ||
| }); | ||
| } else if (value.item.type === 'reasoning') { | ||
| const activeReasoningPart = activeReasoning[value.item.id]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const activeReasoningPart = activeReasoning[value.item.id]; | |
| const activeReasoningPart = activeReasoning[value.item.id]!; |
Missing null check when accessing activeReasoning object. If a response.output_item.done chunk for reasoning arrives before the corresponding response.output_item.added chunk, the code will crash when trying to access .summaryParts on an undefined value.
View Details
Analysis
Missing non-null assertion in OpenAI-compatible responses language model
What fails: TypeScript type checking fails in openai-compatible-responses-language-model.ts at line 565 because activeReasoning[value.item.id] returns a potentially undefined value when accessing a Record, then the code immediately tries to access .summaryParts on line 570 without a null check or non-null assertion.
How to reproduce:
# This would be caught by TypeScript strict type checking
# The code accesses activeReasoning[value.item.id] (type: T | undefined)
# Then immediately accesses .summaryParts on the potentially undefined value
const activeReasoningPart = activeReasoning[value.item.id]; // T | undefined
const summaryPartIndices = Object.entries(activeReasoningPart.summaryParts) // ERRORResult: TypeScript compilation would fail in strict null-checking mode because accessing .summaryParts on a potentially undefined value violates type safety.
Expected: The code should use a non-null assertion consistent with similar accesses in the same file at lines 628, 690, and 696, which all use the non-null assertion operator (!) because the OpenAI Responses API protocol guarantees that response.output_item.added chunks always arrive before corresponding response.output_item.done chunks (evidenced by sequence_number ordering in official test fixtures).
Reference: The fix mirrors the pattern used elsewhere in the same file where activeReasoning[value.item_id]! is used at lines 628, 690, 696 for similar protocol-guaranteed orderings.
packages/openai-compatible/src/responses/openai-compatible-responses-language-model.ts
Show resolved
Hide resolved
- Implement tests for handling empty tools array and undefined tools. - Test preparation of basic function tools with and without strict JSON schema. - Validate multiple function tools preparation. - Include tests for different tool choice scenarios: auto, none, required, specific tool, and undefined choice.
… from convertToOpenAICompatibleResponsesInput
Background
more and more provider supports
v1/responsesendpoint:https://openrouter.ai/docs/api-reference/responses-api/overview
https://docs.x.ai/docs/api-reference#create-new-response
ToDo List:
Summary
Manual Verification
Checklist
pnpm changesetin the project root)Future Work
Related Issues