Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ public record ChatCompletionRequest(// @formatter:off
@JsonProperty("verbosity") String verbosity,
@JsonProperty("prompt_cache_key") String promptCacheKey,
@JsonProperty("safety_identifier") String safetyIdentifier,
Map<String, Object> extraBody) {
@JsonProperty("extra_body") Map<String, Object> extraBody) {

/**
* Compact constructor that ensures extraBody is initialized as a mutable HashMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.ai.openai;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -76,9 +77,13 @@ void whenToolRuntimeOptionsThenMergeWithDefaults() {
@Test
void createRequestWithChatOptions() {
var client = OpenAiChatModel.builder()
.openAiApi(OpenAiApi.builder().apiKey("TEST").build())
.defaultOptions(OpenAiChatOptions.builder().model("DEFAULT_MODEL").temperature(66.6).build())
.build();
.openAiApi(OpenAiApi.builder().apiKey("TEST").build())
.defaultOptions(OpenAiChatOptions.builder()
.model("DEFAULT_MODEL")
.temperature(66.6)
.extraBody(Map.of("key1", "value1"))
.build())
.build();

var prompt = client.buildRequestPrompt(new Prompt("Test message content"));

Expand All @@ -90,6 +95,8 @@ void createRequestWithChatOptions() {
assertThat(request.model()).isEqualTo("DEFAULT_MODEL");
assertThat(request.temperature()).isEqualTo(66.6);

assertThat(request.extraBody().get("key1")).isEqualTo("value1");

request = client.createRequest(new Prompt("Test message content",
OpenAiChatOptions.builder().model("PROMPT_MODEL").temperature(99.9).build()), true);

Expand Down