-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MessageChatMemoryAdvisor results in an error if prompt is initialized with List<Message> instead of userText #2339
Comments
What chat model and chat memory are you using? |
I'm using Azure OpenAI Here is the stack trace..
|
ChatMemory chatMemory = new InMemoryChatMemory();
String content = ChatClient.builder(chatModel).build()
.prompt("hi")
.system("systemText")
.advisors(new MessageChatMemoryAdvisor(chatMemory))
.call()
.content();
System.out.println(content); I have tried testing in the same environment, but it is not reproduced. Could you check if the |
If you create prompt from text it works. You need to create Prompt from a list of messages which contains a UserMessage. I've mentioned this in my first post. The stack trace show an issue on line 97 in MessageChatMemoryAdvisor
It should probably create a UserMessage only if request.userText() is not null. |
This also works. It would be nice if you could provide a more specific example. |
Here is a working example. It's a SpringBoot maven project. The example is a bit about getting the weather in a city. There are two tools provided. getZip() and getWeather(). To get the weather in a city, the LLM should first call the getZip tool to get the zip code and then use the zip code to call the getWeather() function. I'm trying to get the ChatMemory updated with all the messages including the tool call and tool call result. So I'm following the example as suggested in the "User-controlled tool execution" in the Tools documentation. There are 4 files. Set 2 environment variables Access localhost:8080/chat?q=what is the weather in Seattle? On a side note, |
Bug description
Create a prompt with
Prompt prompt = new Prompt(messages); // list of messages including UserMessage
And set MessageChatMemoryAdvisor as an advisor.
Results in an error that Content cannot be null because MessageChatMemoryAdvisor is looking for userText() which is not present but the prompt already has the UserMessage in list of messages.
Environment
Spring AI 1.0.0-SNAPSHOT
SpringBoot 3.4.2
Java 21
The text was updated successfully, but these errors were encountered: