Skip to content

Commit 42022f1

Browse files
ricken07StudiousXiaoYu
authored andcommitted
Resolve Mistral AI Function Call issue and activate testing.
Signed-off-by: Ricken Bazolo <[email protected]> Signed-off-by: StudiousXiaoYu <[email protected]>
1 parent a01a512 commit 42022f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

models/spring-ai-mistral-ai/src/test/java/org/springframework/ai/mistralai/api/tool/MistralAiApiToolFunctionCallIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import com.fasterxml.jackson.core.JsonProcessingException;
2323
import com.fasterxml.jackson.databind.ObjectMapper;
24-
import org.junit.jupiter.api.Disabled;
2524
import org.junit.jupiter.api.Test;
2625
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
2726
import org.slf4j.Logger;
@@ -37,14 +36,15 @@
3736
import org.springframework.ai.mistralai.api.MistralAiApi.FunctionTool.Type;
3837
import org.springframework.ai.model.ModelOptionsUtils;
3938
import org.springframework.http.ResponseEntity;
39+
import org.springframework.util.ObjectUtils;
4040

4141
import static org.assertj.core.api.Assertions.assertThat;
4242

4343
/**
4444
* @author Christian Tzolov
45+
* @author Ricken Bazolo
4546
*/
4647
@EnabledIfEnvironmentVariable(named = "MISTRAL_AI_API_KEY", matches = ".+")
47-
@Disabled
4848
public class MistralAiApiToolFunctionCallIT {
4949

5050
static final String MISTRAL_AI_CHAT_MODEL = MistralAiApi.ChatModel.LARGE.getValue();
@@ -121,7 +121,7 @@ public void toolFunctionCall() throws JsonProcessingException {
121121
assertThat(responseMessage.toolCalls()).isNotNull();
122122

123123
// Check if the model wanted to call a function
124-
if (responseMessage.toolCalls() != null) {
124+
if (!ObjectUtils.isEmpty(responseMessage.toolCalls())) {
125125

126126
// extend conversation with assistant's reply.
127127
messages.add(responseMessage);
@@ -137,7 +137,7 @@ public void toolFunctionCall() throws JsonProcessingException {
137137

138138
// extend conversation with function response.
139139
messages.add(new ChatCompletionMessage("" + weatherResponse.temp() + weatherRequest.unit(),
140-
Role.TOOL, functionName, null));
140+
Role.TOOL, functionName, null, toolCall.id()));
141141
}
142142
}
143143

0 commit comments

Comments
 (0)