Mistral AI streaming function API change fix
This commit is contained in:
@@ -285,7 +285,13 @@ public class MistralAiChatClient extends
|
||||
@SuppressWarnings("null")
|
||||
@Override
|
||||
protected ChatCompletionMessage doGetToolResponseMessage(ResponseEntity<ChatCompletion> chatCompletion) {
|
||||
return chatCompletion.getBody().choices().iterator().next().message();
|
||||
ChatCompletionMessage msg = chatCompletion.getBody().choices().iterator().next().message();
|
||||
if (msg.role() == null) {
|
||||
// add missing role
|
||||
msg = new ChatCompletionMessage(msg.content(), ChatCompletionMessage.Role.ASSISTANT, msg.name(),
|
||||
msg.toolCalls());
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -535,14 +535,12 @@ public class MistralAiApi {
|
||||
*/
|
||||
@JsonProperty("model_length") MODEL_LENGTH,
|
||||
/**
|
||||
* The model called a tool.
|
||||
*
|
||||
*/
|
||||
@JsonProperty("tool_call") TOOL_CALL,
|
||||
|
||||
// anticipation of future changes. Based on:
|
||||
// https://github.com/mistralai/client-python/blob/main/src/mistralai/models/chat_completion.py
|
||||
@JsonProperty("error") ERROR,
|
||||
|
||||
/**
|
||||
* The model requested a tool call.
|
||||
*/
|
||||
@JsonProperty("tool_calls") TOOL_CALLS
|
||||
// @formatter:on
|
||||
|
||||
|
||||
@@ -190,8 +190,7 @@ public class MistralAiStreamFunctionCallingHelper {
|
||||
}
|
||||
|
||||
var choice = choices.get(0);
|
||||
return choice.finishReason() == ChatCompletionFinishReason.TOOL_CALL
|
||||
|| choice.finishReason() == ChatCompletionFinishReason.TOOL_CALLS;
|
||||
return choice.finishReason() == ChatCompletionFinishReason.TOOL_CALLS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user