Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.slf4j.Logger;
Expand All @@ -37,14 +36,15 @@
import org.springframework.ai.mistralai.api.MistralAiApi.FunctionTool.Type;
import org.springframework.ai.model.ModelOptionsUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.util.ObjectUtils;

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

/**
* @author Christian Tzolov
* @author Ricken Bazolo
*/
@EnabledIfEnvironmentVariable(named = "MISTRAL_AI_API_KEY", matches = ".+")
@Disabled
public class MistralAiApiToolFunctionCallIT {

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

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

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

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

Expand Down
Loading