Skip to content

Commit 9d027f6

Browse files
authored
.Net: Fix and put back Ollama tool asserts (#11046)
These were removed in a previous PR as OllamaSharp changed its API and the previous code no longer compiled. This fixes the code and puts it back.
1 parent fc6c2d4 commit 9d027f6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

dotnet/src/Connectors/Connectors.Ollama.UnitTests/Services/OllamaChatCompletionTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ public async Task GetChatMessageContentsShouldAdvertiseToolAsync()
305305
Assert.NotEmpty(requestPayload.Tools);
306306
Assert.Equal(1, requestPayload.Tools?.Count());
307307

308+
var firstTool = JsonSerializer.Deserialize<Tool>((requestPayload.Tools?.Cast<JsonElement>().First()!).Value);
309+
Assert.Equal("TestPlugin_TestFunction", firstTool!.Function!.Name);
310+
Assert.Single(firstTool.Function!.Parameters!.Properties!);
311+
Assert.Equal("testInput", firstTool.Function!.Parameters!.Properties!.First().Key);
312+
Assert.Equal("string", firstTool.Function!.Parameters!.Properties!.First().Value.Type);
313+
Assert.Equal("testInput", firstTool.Function!.Parameters!.Required!.First());
314+
308315
Assert.NotNull(message.ModelId);
309316
Assert.Equal(targetModel, message.ModelId);
310317
Assert.NotNull(message.InnerContent);
@@ -375,6 +382,13 @@ public async Task GetChatMessageContentsShouldAdvertiseAndTriggerToolAsync()
375382
Assert.NotEmpty(requestPayload.Tools);
376383
Assert.Equal(1, requestPayload.Tools?.Count());
377384

385+
var firstTool = JsonSerializer.Deserialize<Tool>((requestPayload.Tools?.Cast<JsonElement>().First()!).Value);
386+
Assert.Equal("TestPlugin_TestFunction", firstTool!.Function!.Name);
387+
Assert.Single(firstTool.Function!.Parameters!.Properties!);
388+
Assert.Equal("testInput", firstTool.Function!.Parameters!.Properties!.First().Key);
389+
Assert.Equal("string", firstTool.Function!.Parameters!.Properties!.First().Value.Type);
390+
Assert.Equal("testInput", firstTool.Function!.Parameters!.Required!.First());
391+
378392
Assert.Equal(1, invocationCount);
379393

380394
Assert.NotNull(message.ModelId);

0 commit comments

Comments
 (0)