Skip to content

Commit f9b4a15

Browse files
authored
.Net: Bugfix for Mistral tool type parameter (#12310)
### Motivation and Context - Fixes #11101
1 parent 71ddf36 commit f9b4a15

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

dotnet/src/Connectors/Connectors.MistralAI.UnitTests/Services/MistralAIChatCompletionServiceTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static void MutateChatHistory(AutoFunctionInvocationContext context, Func<AutoFu
138138
Assert.Equal("assistant", assistantSecondResponse.GetProperty("role").GetString());
139139
Assert.Equal("ejOH4Z1A2", assistantSecondResponse.GetProperty("tool_calls")[0].GetProperty("id").GetString());
140140
Assert.Equal("WeatherPlugin-GetWeather", assistantSecondResponse.GetProperty("tool_calls")[0].GetProperty("function").GetProperty("name").GetString());
141+
Assert.Equal("function", assistantSecondResponse.GetProperty("tool_calls")[0].GetProperty("type").GetString());
141142

142143
var functionResult = messages[4];
143144
Assert.Equal("tool", functionResult.GetProperty("role").GetString());
@@ -211,6 +212,7 @@ static void MutateChatHistory(AutoFunctionInvocationContext context, Func<AutoFu
211212
Assert.Equal("assistant", assistantSecondResponse.GetProperty("role").GetString());
212213
Assert.Equal("u2ef3Udel", assistantSecondResponse.GetProperty("tool_calls")[0].GetProperty("id").GetString());
213214
Assert.Equal("WeatherPlugin-GetWeather", assistantSecondResponse.GetProperty("tool_calls")[0].GetProperty("function").GetProperty("name").GetString());
215+
Assert.Equal("function", assistantSecondResponse.GetProperty("tool_calls")[0].GetProperty("type").GetString());
214216

215217
var functionResult = messages[4];
216218
Assert.Equal("tool", functionResult.GetProperty("role").GetString());

dotnet/src/Connectors/Connectors.MistralAI/Client/MistralToolCall.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ internal sealed class MistralToolCall
1313
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1414
public string? Id { get; set; }
1515

16+
[JsonPropertyName("type")]
17+
public string Type { get; set; } = "function";
18+
1619
[JsonPropertyName("function")]
1720
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
1821
public MistralFunction? Function { get; set; }

dotnet/src/IntegrationTests/Connectors/MistralAI/ChatCompletion/MistralAIChatCompletionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ public async Task ValidateGetChatMessageContentsWithAutoInvokeAndMultipleCallsAs
507507
var executionSettings = new MistralAIPromptExecutionSettings { ToolCallBehavior = MistralAIToolCallBehavior.AutoInvokeKernelFunctions };
508508
var result1 = await service.GetChatMessageContentsAsync(chatHistory, executionSettings, kernel);
509509
chatHistory.AddRange(result1);
510-
chatHistory.Add(new ChatMessageContent(AuthorRole.User, "What is the weather like in Marseille?"));
510+
chatHistory.Add(new ChatMessageContent(AuthorRole.User, "What is the weather temperature in Marseille?"));
511511
var result2 = await service.GetChatMessageContentsAsync(chatHistory, executionSettings, kernel);
512512

513513
// Assert

0 commit comments

Comments
 (0)