2121
2222import com .fasterxml .jackson .core .JsonProcessingException ;
2323import com .fasterxml .jackson .databind .ObjectMapper ;
24- import org .junit .jupiter .api .Disabled ;
2524import org .junit .jupiter .api .Test ;
2625import org .junit .jupiter .api .condition .EnabledIfEnvironmentVariable ;
2726import org .slf4j .Logger ;
3736import org .springframework .ai .mistralai .api .MistralAiApi .FunctionTool .Type ;
3837import org .springframework .ai .model .ModelOptionsUtils ;
3938import org .springframework .http .ResponseEntity ;
39+ import org .springframework .util .ObjectUtils ;
4040
4141import 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
4848public 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