feat: Add OAI_RESPONSES model provider and implement Responses API client tests

- Updated ModelProfile to include OAI_RESPONSES in the ModelProvider enum.
- Created CompletionClientTest to validate text and chat completion functionalities.
- Added ResponsesApiClientTest to test Responses API interactions, including model listing and conversation handling.
- Implemented ResponsesApiDialectTestConfiguration for managing reasoning efforts in tests.
- Updated application-test.properties to include a new profile for responses.
- Added local-responses.properties configuration for the Responses API.
This commit is contained in:
extio-de
2026-05-14 20:26:59 +02:00
parent e3dda708f2
commit 12a90917ee
15 changed files with 1950 additions and 21 deletions

View File

@@ -3,8 +3,22 @@ package de.extio.lmlib.client;
import java.math.BigDecimal;
import java.time.Duration;
import java.util.List;
import java.util.Map;
public final record Completion(String response, String reasoning, CompletionFinishReason finishReason, CompletionStatistics statistics, List<ToolCall> toolCalls) {
/**
* Normalized result returned by lm-lib clients.
*
* @param response the assistant-visible text output
* @param reasoning the separately exposed reasoning summary or reasoning text
* @param finishReason why generation stopped
* @param statistics token, duration, cache, and cost accounting for the request
* @param toolCalls tool calls returned by the provider when the response stopped
* for tool execution
* @param outputItems provider-specific structured output items that need to
* survive follow-up rounds, primarily for stateless OpenAI Responses tool
* loops
*/
public final record Completion(String response, String reasoning, CompletionFinishReason finishReason, CompletionStatistics statistics, List<ToolCall> toolCalls, List<Map<String, Object>> outputItems) {
public Completion {
response = response == null ? "" : response;
@@ -12,10 +26,22 @@ public final record Completion(String response, String reasoning, CompletionFini
finishReason = finishReason == null ? CompletionFinishReason.DONE : finishReason;
statistics = statistics == null ? new CompletionStatistics(0, Duration.ZERO, 0, 0, 0, 0, BigDecimal.ZERO, false) : statistics;
toolCalls = toolCalls == null ? List.of() : List.copyOf(toolCalls);
outputItems = outputItems == null ? List.of() : outputItems.stream().map(outputItem -> outputItem == null ? Map.<String, Object>of() : Map.copyOf(outputItem)).toList();
}
/**
* Creates a completion without provider-specific output items.
*/
public Completion(final String response, final String reasoning, final CompletionFinishReason finishReason, final CompletionStatistics statistics, final List<ToolCall> toolCalls) {
this(response, reasoning, finishReason, statistics, toolCalls, List.of());
}
/**
* Creates a plain text completion without tool calls or provider-specific
* output items.
*/
public Completion(final String response, final String reasoning, final CompletionFinishReason finishReason, final CompletionStatistics statistics) {
this(response, reasoning, finishReason, statistics, List.of());
this(response, reasoning, finishReason, statistics, List.of(), List.of());
}
}