Skip to content

Conversation

@svilupp
Copy link
Owner

@svilupp svilupp commented Nov 28, 2025

This PR supersedes #316

Added support for OpenAI's Responses API (/responses endpoint) via OpenAIResponseSchema. Supports reasoning traces, multi-turn conversations with previous_response_id, and structured extraction with aiextract. Use aigenerate(OpenAIResponseSchema(), prompt; model="o4-mini") for reasoning models (access via result.extras[:reasoning_content]).

Note: Many features are not supported yet, eg, streaming, built-in tools, etc.

Thanks to @Sixzero for the first draft!

This PR adds support for OpenAI's Responses API (/responses endpoint)
used by models like gpt-5.1-codex, addressing review feedback from PR #316:

File organization:
- Renamed llm_openai.jl to llm_openai_chat.jl for clarity
- Created llm_openai_responses.jl for Responses API implementation
- Added documentation in llm_interface.jl explaining OpenAI file structure

API consistency:
- Replaced render_responses with unified render(schema::AbstractResponseSchema, ...)
- Removed duplicative replace_placeholders function (uses render(NoSchema, ...) instead)
- Fixed API key handling to use empty string default with ENV fallback

Testing:
- Added TestEchoOpenAIResponseSchema for testing
- Created comprehensive test suite in test/llm_openai_responses.jl
- All tests pass with 1856 passed, 0 failed

Note: Uses OpenAIStream for streaming until ResponseStream is available
in StreamCallbacks.jl
This PR adds support for OpenAI's Responses API (/responses endpoint)
used by reasoning models (o1, o3) and code models (gpt-5.1-codex).

File organization:
- Renamed llm_openai.jl to llm_openai_chat.jl for clarity
- Created llm_openai_responses.jl for Responses API implementation
- Added documentation in llm_interface.jl explaining OpenAI file structure

Key features:
- aigenerate with OpenAIResponseSchema for basic generation
- aiextract for structured extraction (reuses tool_call_signature and parse_tool)
- Multi-turn conversations via previous_response_id (no need to re-send history)
- Reasoning control via api_kwargs (effort: low/medium/high, summary: concise/detailed)
- Reasoning traces accessible via response.extras[:reasoning_content]
- Web search integration via enable_websearch=true

API consistency:
- Unified render(schema::AbstractResponseSchema, ...) function
- API key handling with empty string default and ENV fallback
- No reasoning added by default (only when specified)

Testing:
- Added TestEchoOpenAIResponseSchema for testing
- Comprehensive test suite including aiextract and reasoning extraction
- All tests pass (1868 passed, 7 pre-existing broken)

Added examples/working_with_responses_api.jl demonstrating all features.
@codecov
Copy link

codecov bot commented Nov 28, 2025

Codecov Report

❌ Patch coverage is 86.20690% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.08%. Comparing base (6447570) to head (a4d5a4a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/llm_openai_responses.jl 86.20% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
+ Coverage   92.05%   92.08%   +0.03%     
==========================================
  Files          38       38              
  Lines        3346     3384      +38     
==========================================
+ Hits         3080     3116      +36     
- Misses        266      268       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@svilupp svilupp merged commit 4a5af48 into main Nov 28, 2025
6 of 7 checks passed
@svilupp svilupp deleted the openai-responses branch November 28, 2025 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants