spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/index.html
Apache License 2.0
3.19k stars 810 forks source link

[Bug] Is there a default AzureOpenAiChatOptions available? #1414

Closed zhengjian2016 closed 1 month ago

zhengjian2016 commented 1 month ago

About below code:

chatClient = ChatClient.create(chatModel);
chatClient = ChatClient.builder(chatModel).build();

It's working for OpenAiChatModel and OllamaChatModel

Actually, it was working for AzureOpenAiChatModel as well before spring-ai-azure-openai-1.0.0-20240925 , but I'm not sure what date the jar was from. But it isn't working for AzureOpenAiChatModel now, due to the following error: "responseFormat must not be null"

It's from the following class: spring-ai-azure-openai/1.0.0-SNAPSHOT /spring-ai-azure-openai-1.0.0-20240925.165056-619.jar! /org/springframework/ai/azure/openai/AzureOpenAiChatOptions.class

Assert.notNull(responseFormat, "responseFormat must not be null");

Is there a default AzureOpenAiChatOptions available?

Issue Category

Product Versions

Desired Behavior

Actually, I want to use the default AzureOpenAiChatOptions without having to set them myself, as I don't know how to properly configure them. I currently don't care about these options, but:

Is there a default AzureOpenAiChatOptions available?

Observed Behavior

I've tried below approach but it's not working:

AzureOpenAiChatOptions.ResponseFormat responseFormat = AzureOpenAiChatOptions.ResponseFormat.TEXT;
AzureOpenAiChatOptions chatOptions = AzureOpenAiChatOptions.builder()
    .withDeploymentName("gpt-4o")
    .withTemperature(0.7)
    .withResponseFormat(responseFormat)
    .build();

I got the following error: "seed must not be null"

bala-ayalur commented 1 month ago

I faced the same issue and switched back to the 1.0.0-20240919.222959-603 version of spring-ai-azure-openai for now.

sobychacko commented 1 month ago

This was a bug and was fixed very recently via https://github.com/spring-projects/spring-ai/commit/e29d38d987d9aabdb35cf87321b13bb33dbdb871. Please try the latest snapshots. Thanks!