-
[OPIK-6833][BE] Support OpenAI Responses API for the OpenAI provider (Playground & LLM-as-a-Judge) (#7008)
发布于
2026-06-12 10:58:51 +00:00 - [OPIK-6833] Add support for OpenAI Responses API in client generator
- Introduced
ApiPipelineModeenum to toggle between Chat Completions API and Responses API. - Implemented
extractApiPipelineModefor dynamic pipeline mode detection. - Added
newResponsesApiChatModelfor modern Responses API support. - Updated dependencies to include
langchain4j-open-ai-officialfor the Responses API.
- [OPIK-6833] Migrate client generation to OpenAI official SDK and refactor timeout/logging configurations
- Updated
OpenAIClientGeneratorto utilize the official OpenAI SDK (OpenAIOkHttpClient). - Added support for
TimeoutandLogLevelsettings directly in the client configuration. - Refactored timeout configuration into a dedicated
buildTimeoutmethod. - Updated header configuration to align with the SDK's requirements and support multiple values per key.
- [OPIK-6833] Add support for OpenAI Responses API and implement associated mappers and tests
- Introduced
LlmProviderOpenAiResponsesfor interfacing with OpenAI Responses API. - Added
LlmProviderOpenAiResponsesMapperto handle DTO transformations between OpenAI and LangChain4j. - Refactored
OpenAIClientGeneratorto contextualize pipeline modes and instantiate appropriate clients. - Extended unit and integration tests for
Responses APIcompatibility and validation, including mapper tests. - Updated
OpenAILlmServiceProviderto integrate Responses API within service extraction logic.
- [OPIK-6833] Add streaming support for OpenAI Responses API with client extensions and tests
- Implemented
newResponsesApiStreamingChatModelfor streaming inOpenAIClientGenerator. - Extended
LlmProviderOpenAiResponsesto support streaming viaStreamingChatModel. - Updated mappers in
LlmProviderOpenAiResponsesMapperto handle streaming partial and final chunks. - Added tests for
LlmProviderOpenAiResponsescovering happy path, error cases, and realistic streaming scenarios. - Refactored
OpenAILlmServiceProviderto integrate streaming configurations.
- [OPIK-6833] Add tool-calling support in OpenAI Responses API mapper with tests
- Extended
LlmProviderOpenAiResponsesMapperto integrate tool specifications, tool calls, and tool result messages. - Implemented bidirectional transformations for tool-related constructs between LangChain4j and OpenAI formats.
- Enhanced
LlmProviderOpenAiResponsesTestwith end-to-end tool loop round-trip scenarios. - Updated
LlmProviderOpenAiResponsesto handle multi-turn tool interaction workflows. - Added comprehensive unit and integration tests covering tool-calling behaviors.
- [OPIK-6833] Add structured response format support with JSON object and schema mappings in OpenAI Responses API mapper
- Enhanced
LlmProviderOpenAiResponsesMapperto support structured response formats (json_objectandjson_schema). - Implemented bidirectional mapping for JSON schema and object formats between OpenAI and LangChain4j.
- Added tests for structured output scenarios, ensuring correct handling for schema-based responses and different format types.
- Included defensive logic for schema-less response formats and null response cases.
- [OPIK-6833] Add pipeline mode selection for OpenAI in ManageAIProviderDialog
- Introduced a dropdown for selecting OpenAI pipeline modes (Chat Completions API or Responses API) in
CloudAIProviderDetails. - Updated form schema and state management to handle
openaiPipelineMode. - Enhanced backend configuration logic to persist and pass pipeline mode settings for OpenAI providers.
- Added contextual descriptions to assist users in selecting the appropriate pipeline mode.
-
[OPIK-6833] Fix missing newline at EOF in CloudAIProviderDetails file
-
[OPIK-6833] Add strict JSON schema support and enhance error handling in OpenAI Responses API
- Updated
OpenAIClientGeneratorto support strict JSON schema mode via new overloads fornewResponsesApiChatModelandnewResponsesApiStreamingChatModel. - Enhanced
LlmProviderOpenAiResponsesMapperto extract and validate strict mode from request response formats. - Refactored
LlmProviderOpenAiResponsesto build chat models per request, incorporating strict flag propagation. - Improved error handling for unsupported tool choices with explicit exceptions for named function specifications.
- Added new test coverage for strict JSON schema handling, loose mode fallback, and error scenarios.
- [OPIK-6833] Centralize default OpenAI pipeline mode in ManageAIProviderDialog schema
- Introduced
DEFAULT_OPENAI_PIPELINE_MODEconstant for consistent fallback handling of OpenAI pipeline modes. - Replaced hardcoded "chat_completions_api" with
DEFAULT_OPENAI_PIPELINE_MODEacross form defaults, resets, and save payloads inManageAIProviderDialog.
- [OPIK-6833] Normalize OpenAI pipeline mode handling in ManageAIProviderDialog
- Introduced
normalizeOpenAiPipelineModeutility to ensure consistent casing and fallback logic foropenaiPipelineMode. - Updated form schema and state management in
ManageAIProviderDialogto use the normalization function. - Improved handling of legacy or improperly cased
openaiPipelineModevalues.
-
[OPIK-6833] Fixed ESLint issue
-
[OPIK-6833] Drop unsupported parameters in OpenAI Responses API mapper
- Removed unsupported fields (
frequency_penalty,presence_penalty) from requests to prevent validation failures. - Added warnings for dropped parameters via new
warnIfDroppedSamplingParammethod. - Introduced handling for
OpikUserMessageto ensure proper mapping of custom multimodal messages. - Updated and extended test coverage for the new behaviors and edge cases.
- [OPIK-6833] Improve OpenAI Responses API error handling and status mapping
- Added mapping for "unsupported_parameter" errors to HTTP 400 in
OpenAiCompatStatusCodes. - Enhanced error extraction in
LlmProviderOpenAiResponsesto handleOpenAIServiceExceptionand provide precise diagnostic information. - Introduced fallback logic for unrecognized error codes using high-level types or status codes.
- Updated tests to cover new error-handling logic, including nested exceptions and fallback scenarios.
- [OPIK-6833] Strip unsupported
top_pparameter for OpenAI reasoning models
- Updated
modelUtilsto removetop_pfor reasoning models, preventing 400 errors due to unsupported parameters. - Modified
PromptModelSettingsto hidetop_pslider for applicable models in the UI. - Added tests to ensure consistent clearing of stale
top_pvalues during configuration updates and request sanitization.
- [OPIK-6833] Replace
Selectcomponent withSelectBoxin CloudAIProviderDetails
- Updated pipeline mode selection to use the
SelectBoxcomponent for improved consistency and code simplification. - Adjusted type definitions and form handling to align with the new dropdown component.
- [OPIK-6833] Centralize OpenAI pipeline mode values in
types/providers
- Moved
OPENAI_PIPELINE_MODE_VALUESandOpenAiPipelineModetype totypes/providersfor reusability and consistency. - Updated
ManageAIProviderDialogschema to import and use centralized pipeline mode definitions.
- [OPIK-6833] Refine OpenAI pipeline mode handling in ManageAIProviderDialog
- Ensured that
openaiPipelineModeis safely seeded in form defaults for OpenAI configurations. - Removed redundant
DEFAULT_OPENAI_PIPELINE_MODEusage, relying instead on guaranteed non-null assertions. - Updated related form handling and comments for clarity and maintainability.
- [OPIK-6833] Extract
OpenAiResponsesStreamingHandlerfor response handling
- Moved inline
StreamingChatResponseHandlerimplementation toOpenAiResponsesStreamingHandlerfor clarity and reusability. - Updated
LlmProviderOpenAiResponsesto use the new handler class while preserving existing functionality.
- [OPIK-6833] Refactor tests and replace inline request creation with reusable builder methods
- Consolidated repetitive
ChatCompletionRequest.builder()calls into reusable helper methods to improve test readability and maintainability. - Updated all relevant tests to utilize
requestBuildervariants. - Adjusted constants and mapping logic for consistency with OpenAI Responses API requirements, including
modelNameplaceholder updates. - Improved assertions to dynamically adapt to request fields, reducing hardcoded values.
下载附件