Skip to content

Commit

Permalink
Mistral: map toolCallId for tool messages (langchain4j#2278)
Browse files Browse the repository at this point in the history
## Change
Mistral tests are currently fail because all of a sudden Mistral decided
to make `tool_call_id` parameter in `tool` messages mandatory:
`Runtime java.lang.RuntimeException: status code: 400; body:
{"object":"error","message":"Tool call id has to be
defined.","type":"invalid_request_error","param":null,"code":null}`.

This probably affects all Mistral users using tools.

cc @geoand 

## General checklist
- [X] There are no breaking changes
- [ ] I have added unit and/or integration tests for my change
- [ ] The tests cover both positive and negative cases
- [X] I have manually run all the unit and integration tests in the
module I have added/changed, and they are all green
- [ ] I have manually run all the unit and integration tests in the
[core](https://github.com/langchain4j/langchain4j/tree/main/langchain4j-core)
and
[main](https://github.com/langchain4j/langchain4j/tree/main/langchain4j)
modules, and they are all green
- [ ] I have added/updated the
[documentation](https://github.com/langchain4j/langchain4j/tree/main/docs/docs)
- [ ] I have added an example in the [examples
repo](https://github.com/langchain4j/langchain4j-examples) (only for
"big" features)
- [ ] I have added/updated [Spring Boot
starter(s)](https://github.com/langchain4j/langchain4j-spring) (if
applicable)
  • Loading branch information
dliubarskyi authored Dec 16, 2024
1 parent f9b5eae commit 14c9693
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ public class MistralAiChatMessage {
private String content;
private String name;
private List<MistralAiToolCall> toolCalls;
private String toolCallId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static MistralAiChatMessage toMistralAiMessage(ChatMessage message) {
if (message instanceof ToolExecutionResultMessage) {
return MistralAiChatMessage.builder()
.role(MistralAiRole.TOOL)
.toolCallId(((ToolExecutionResultMessage) message).id())
.name(((ToolExecutionResultMessage) message).toolName())
.content(((ToolExecutionResultMessage) message).text())
.build();
Expand Down

0 comments on commit 14c9693

Please sign in to comment.