Bug description
Getting this error when trying to access the vision capability using ChatClient:
java.lang.IllegalStateException: No CallAdvisors available to execute
Environment
- Java version: 21
- Spring AI version: 1.0.0
- Project: multimodal-llms
Steps to reproduce
1. Clone the multimodal-llms project from this link.
2. In VisionController.java, comment out this line:
defaultAdvisors
3. Start the app by running MultimodalLLMApplication.java:
MultimodalLLMApplication.java
4. Hit the following curl command:
```bash
curl --request POST \
--url http://localhost:8083/springai/v2/vision \
--header 'Content-Type: multipart/form-data' \
--form file=@/Users/dilipbandlasundarraj/Dilip/code-with-dilip/spring-ai/multimodal-llms/src/main/resources/files/vision/pizza.png \
--form 'prompt=Explain what do you see in this picture?. Summarize it like an attractive menu item name.'
Expected behavior The vision capability should work even without explicitly adding an advisor in the ChatClient.
Minimal Complete Reproducible example The issue can be reproduced using the multimodal-llms sample project. Comment out this line: VisionController.java#L39 Then hit the POST /springai/v2/vision endpoint.
Fix This endpoint works only when the following advisor is explicitly added in the controller constructor:
public VisionController(ChatClient.Builder chatClientBuilder,
OpenAiChatModel openAiChatModel) {
this.openAiChatModel = openAiChatModel;
var advisor = ChatModelCallAdvisor.builder()
.chatModel(openAiChatModel)
.build();
this.chatClient = chatClientBuilder
.defaultAdvisors(advisor)
.build();
}
Source: VisionController.java#L39
Comment From: salaboy
@dilipsundarraj1 I've started having the same issue, but not sure what changed on my project. It was working as expected and then something changed and I started getting this exception.
Comment From: Hassen-BENNOUR
I've had the same problem since version 1.1.0 of spring.ai. java.lang.IllegalStateException: No CallAdvisors available to execute at org.springframework.ai.chat.client.advisor.DefaultAroundAdvisorChain.nextCall(DefaultAroundAdvisorChain.java:99) ~[spring-ai-client-chat-1.1.0.jar:1.1.0]
Comment From: Hassen-BENNOUR
@salaboy @dilipsundarraj1 I found it!
I recently made the same modification, calling the methods twice (chatResponse(), content(), or chatClientResponse()) which return the results and restart the call chain to the advisors, overriding the default org.springframework.ai.chat.client.advisor.ChatModelCallAdvisor.
So you have to call it once chatResponse() or content() in your code https://github.com/dilipsundarraj1/spring-ai/blob/ee5fae83afa843a383fecfb72b68e904d3f3afe5/multimodal-llms/src/main/java/com/llm/vision/VisionController.java#L77-L78