Skip to content
Merged
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 @@ -141,6 +141,11 @@ public class OpenAiChatOptions implements FunctionCallingOptions, ChatOptions {
* A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
*/
private @JsonProperty("user") String user;
/**
* Whether to enable <a href="https://platform.openai.com/docs/guides/function-calling/parallel-function-calling">parallel function calling</a> during tool use.
* Defaults to true.
*/
private @JsonProperty("parallel_tool_calls") Boolean parallelToolCalls;

/**
* OpenAI Tool Function Callbacks to register with the ChatModel.
Expand Down Expand Up @@ -272,6 +277,11 @@ public Builder withUser(String user) {
return this;
}

public Builder withParallelToolCalls(Boolean parallelToolCalls) {
this.options.parallelToolCalls = parallelToolCalls;
return this;
}

public Builder withFunctionCallbacks(List<FunctionCallback> functionCallbacks) {
this.options.functionCallbacks = functionCallbacks;
return this;
Expand Down Expand Up @@ -441,6 +451,14 @@ public void setUser(String user) {
this.user = user;
}

public Boolean getParallelToolCalls() {
return this.parallelToolCalls;
}

public void setParallelToolCalls(Boolean parallelToolCalls) {
this.parallelToolCalls = parallelToolCalls;
}

@Override
public List<FunctionCallback> getFunctionCallbacks() {
return this.functionCallbacks;
Expand Down Expand Up @@ -481,6 +499,7 @@ public int hashCode() {
result = prime * result + ((tools == null) ? 0 : tools.hashCode());
result = prime * result + ((toolChoice == null) ? 0 : toolChoice.hashCode());
result = prime * result + ((user == null) ? 0 : user.hashCode());
result = prime * result + ((parallelToolCalls == null) ? 0 : parallelToolCalls.hashCode());
return result;
}

Expand Down Expand Up @@ -595,6 +614,13 @@ else if (!toolChoice.equals(other.toolChoice))
}
else if (!this.user.equals(other.user))
return false;
else if (this.parallelToolCalls == null) {
if (other.parallelToolCalls != null)
return false;
}
else if (!this.parallelToolCalls.equals(other.parallelToolCalls))
return false;

return true;
}

Expand Down Expand Up @@ -633,6 +659,7 @@ public static OpenAiChatOptions fromOptions(OpenAiChatOptions fromOptions) {
.withTools(fromOptions.getTools())
.withToolChoice(fromOptions.getToolChoice())
.withUser(fromOptions.getUser())
.withParallelToolCalls(fromOptions.getParallelToolCalls())
.withFunctionCallbacks(fromOptions.getFunctionCallbacks())
.withFunctions(fromOptions.getFunctions())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ The prefix `spring.ai.openai.chat` is the property prefix that lets you configur
| spring.ai.openai.chat.options.user | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. | -
| spring.ai.openai.chat.options.functions | List of functions, identified by their names, to enable for function calling in a single prompt requests. Functions with those names must exist in the functionCallbacks registry. | -
| spring.ai.openai.chat.options.stream-usage | (For streaming only) Set to add an additional chunk with token usage statistics for the entire request. The `choices` field for this chunk is an empty array and all other chunks will also include a usage field, but with a null value. | false
| spring.ai.openai.chat.options.parallel-tool-calls | Whether to enable link:https://platform.openai.com/docs/guides/function-calling/parallel-function-calling[parallel function calling] during tool use. | true
|====

NOTE: You can override the common `spring.ai.openai.base-url` and `spring.ai.openai.api-key` for the `ChatModel` and `EmbeddingModel` implementations.
Expand Down