Bug description
Consider the attributes that can be set through AzureOpenAiChatOptions
:
- maxTokens
- temperature
- topP
- logitBias
- user
- n
- stop
- presencePenalty
- frequencyPenalty
- deploymentName
- responseFormat
- functionCallbacks
- functions
The AzureOpenAiChatOptions
object is used in the AzureOpenAiChatModel
to create the instance of ChatCompletionsOptions
.
ChatCompletionsOptions
has the following attributes:
- messages
- maxTokens
- temperature
- topP
- logitBias
- user
- n
- stop
- presencePenalty
- frequencyPenalty
- stream
- model
- functions
- functionCall
- functionCallConfig
- dataSources
- enhancements
- seed
- responseFormat
- tools
- toolChoice
- logprobs
- topLogprobs
In code it seems like there's no way to set options like logprobs, enhancements or seed.
Furthermore, in the method that should merge two ChatCompletionsOptions
:
private ChatCompletionsOptions merge(ChatCompletionsOptions fromOptions, ChatCompletionsOptions toOptions)
such options are not taken into account
Expected behavior
I'm expecting the AzureOpenAiChatOptions
to be aligned with the currently available options for Azure OpenAi
Comment From: pradu3
Hi All!
This change is not working and is breaking things. It is adding the new options but makes more of them indirectly mandatory.
The Assert.notNull
checks in AzureOpenAiChatOptions.Builder.with*
make the attributes actually mandatory. AzureOpenAiChatOptions.fromOptions
is called from AzureOpenAiChatModel.getDefaultOptions
. When the AzureOpenAiChatModel.defaultOption
attribute doesn't have all the checked fields set (e.g. seed
), there will be an exception when AzureOpenAiChatModel.getDefaultOptions
. This will cause, for example, ChatClient.create
to fail. This happen even when the AzureOpenAiChatModel( OpenAIClient microsoftOpenAiClient)
constructor is used.
Caused by: java.lang.IllegalArgumentException: seed must not be null
at org.springframework.util.Assert.notNull(Assert.java:172) ~[spring-core-6.1.13.jar:6.1.13]
at org.springframework.ai.azure.openai.AzureOpenAiChatOptions$Builder.withSeed(AzureOpenAiChatOptions.java:297) ~[spring-ai-azure-openai-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.azure.openai.AzureOpenAiChatOptions.fromOptions(AzureOpenAiChatOptions.java:525) ~[spring-ai-azure-openai-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.azure.openai.AzureOpenAiChatModel.getDefaultOptions(AzureOpenAiChatModel.java:143) ~[spring-ai-azure-openai-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.azure.openai.AzureOpenAiChatModel.getDefaultOptions(AzureOpenAiChatModel.java:100) ~[spring-ai-azure-openai-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.chat.client.DefaultChatClient$DefaultChatClientRequestSpec.<init>(DefaultChatClient.java:722) ~[spring-ai-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.chat.client.DefaultChatClientBuilder.<init>(DefaultChatClientBuilder.java:62) ~[spring-ai-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.chat.client.ChatClient.builder(ChatClient.java:72) ~[spring-ai-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.chat.client.ChatClient.create(ChatClient.java:63) ~[spring-ai-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.chat.client.ChatClient.create(ChatClient.java:58) ~[spring-ai-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
at org.springframework.ai.chat.client.ChatClient.create(ChatClient.java:54) ~[spring-ai-core-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
Since we would anyhow ignore null options with @JsonInclude(nclude.NON_NULL)
on AzureOpenAiChatOptions
, there is no added value for having those checks on .with* methods.
Comment From: markpollack
will take a look, thanks for reporting.
Comment From: markpollack
this issue has been fixed. thanks for hanging in there... see 56a41e6