-
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. |
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: