spring-projects / spring-ai

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

OpenAI Auto Configuration failing to apply Webclient configuration instead of RestClient. #1066

Open Adakole2020 opened 1 month ago

Adakole2020 commented 1 month ago

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create. If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description The OpenAI autoconfiguration relies on an import of the restclient autoconfiguration or a webclient autoconfiguration. Commit 377b5ff attempts to fix it but fails to handle the situation when either is null. An @nullable annotation on both followed by a later check might be ideal.

Screenshot 2024-07-17 at 2 19 50 PM

Environment Spring-AI: 1.0.0-M1 Java: 21

Steps to reproduce Initiate chatClient in a reactive setup with no non-reactive dependency inclusions.

Screenshot 2024-07-17 at 2 19 01 PM
tzolov commented 1 month ago

Can you please share the complete error stack trace?

Adakole2020 commented 1 month ago

Does this suffice?

Unsatisfied dependency expressed through constructor parameter 0: 
Error creating bean with name 'chatClientBuilder' defined in class path resource [org/springframework/ai/autoconfigure/chat/client/ChatClientAutoConfiguration.class]: Unsatisfied dependency expressed through method 'chatClientBuilder' parameter 1: 
Error creating bean with name 'openAiChatModel' defined in class path resource [org/springframework/ai/autoconfigure/openai/OpenAiAutoConfiguration.class]: Unsatisfied dependency expressed through method 'openAiChatModel' parameter 2: 
No qualifying bean of type 'org.springframework.web.client.RestClient$Builder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}