Bug description If I use MistralAiChatModel with MessageChatMemoryAdvisor + InMemoryChatMemory, at the second iteration, I get the following erorr: Unexpected role 'system' after role 'assistant'
At the second iteration the system role
appears after the previous user role
and assistant role
messages and before the current user role
message.
"messages": [
{
"content": "first user message is here",
"role": "user"
},
{
"content": "first assistant message is here",
"role": "assistant"
},
{
"content": " You are an assistant helping people to buy tickets for trains, give the answer with the same language of the request.\n The answer must be formated as MarkDown.\n",
"role": "system"
},
{
"content": "currentuser message is here",
"role": "user"
}
]
Environment Spring AI 1.0.0-M6, Java version 21
Steps to reproduce add the following fragment to the pom.xml
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-mistral-ai-spring-boot-starter</artifactId>
</dependency>
use the following fragment of code
ChatClient.Builder builder
chatClient = builder
.defaultAdvisors(new MessageChatMemoryAdvisor(new InMemoryChatMemory()))
.build();
Expected behavior MistralAi LLM wants the system role to be the first one and this can be a general rule for all LLM.
Comment From: bordis
Hello, I just have this problem testing the mystral model.. This issue is open, but I saw #2541 closed, is it the same problem?
Thanks!