feat: response merging, JSON auto-stringify, and openai-responses migration#111
Merged
feat: response merging, JSON auto-stringify, and openai-responses migration#111
Conversation
commit: |
7eb1c5a to
ec66322
Compare
Add ResponseOverrides interface for overriding envelope fields (id, created, model, usage, finishReason, role, systemFingerprint) in fixture responses. Thread overrides through all 4 provider handlers (OpenAI Chat, Responses API, Claude Messages, Gemini) for both streaming and non-streaming paths. Add normalizeResponse() for auto-stringifying object-valued content and toolCalls[].arguments in fixtures — lets authors write plain JSON objects instead of escaped strings. FixtureFile* types accept relaxed input while runtime types remain strict. Type safety improvements: - Add system_fingerprint to SSEChunk/ChatCompletion types - Make type guards mutually exclusive (isTextResponse excludes toolCalls) - Narrow extractOverrides parameter type - Remove unnecessary as-casts Cross-provider consistency: - finishReason mappings: length, content_filter for all providers - Usage auto-sum: total_tokens computed from components when omitted - Reasoning support for ContentWithToolCallsResponse in all providers - webSearches warnings for unsupported providers Validation: ResponseOverrides field type checks, unknown field detection, unknown usage key detection, ContentWithToolCallsResponse validation.
55 new tests across 4 test files: - response-overrides.test.ts: override propagation for all providers (streaming + non-streaming), cross-provider finishReason mappings (stop, tool_calls, length, content_filter), usage auto-sum and partial merge per provider, CWTC with overrides/reasoning/webSearches, extractOverrides unit tests - fixture-loader.test.ts: auto-stringify edge cases (arrays, null, mixed types, immutability), validation for all override fields, ContentWithToolCallsResponse validation, unknown field/usage detection - content-with-toolcalls.test.ts: multi-tool-call streaming for OpenAI/Claude/Gemini, type guard mutual exclusivity - llmock.test.ts: programmatic API override passthrough via on()
- Migration guide from openai-responses-python - Fixtures docs: Response Override Fields table, provider support matrix, ContentWithToolCallsResponse row, finishReason/usage mapping details - SKILL.md: complete override field docs with provider support matrix, finishReason translation table, usage auto-compute notes - Convert all fixture examples to object syntax (auto-stringify) - Fix provider count to 8, finishReason to camelCase in README - Remove stale TODO in stream-collapse.ts
f71127c to
320d466
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
id,created,model,usage,finishReason,role,systemFingerprinton fixture responses across all 4 provider formats (OpenAI, Claude, Gemini, Responses API), streaming and non-streamingargumentsandcontentaccept objects (auto-stringified by loader AND programmatic API), eliminating escaped JSON paindocs/migrate-from-openai-responses/targeting ~8.5K weekly PyPI users with accurate before/after examplesrole/finishReasonconsolidated intoResponseOverrides,FixtureFile*types extendResponseOverrides,validateFixturesrecognizes all response typesResponseOverrides,ContentWithToolCallsResponse,FixtureFileResponse,FixtureFileToolCallskills/write-fixtures/SKILL.mdand docs pages updated for new featuresTest plan