Resolve Mistral AI Function Call issue and activate testing.
Signed-off-by: Ricken Bazolo <ricken.bazolo@gmail.com>
This commit is contained in:
committed by
Ilayaperumal Gopinathan
parent
b77e084bf9
commit
a0e0508cc0
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
|
||||
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;
|
||||
@@ -37,14 +36,15 @@ import org.springframework.ai.mistralai.api.MistralAiApi.ChatCompletionRequest.T
|
||||
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();
|
||||
@@ -121,7 +121,7 @@ public class MistralAiApiToolFunctionCallIT {
|
||||
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);
|
||||
@@ -137,7 +137,7 @@ public class MistralAiApiToolFunctionCallIT {
|
||||
|
||||
// extend conversation with function response.
|
||||
messages.add(new ChatCompletionMessage("" + weatherResponse.temp() + weatherRequest.unit(),
|
||||
Role.TOOL, functionName, null));
|
||||
Role.TOOL, functionName, null, toolCall.id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user