Skip to content

Commit

Permalink
Fixed streaming function tool serialization (#187)
Browse files Browse the repository at this point in the history
- fixes: #186
  • Loading branch information
Mitch528 authored Nov 27, 2023
1 parent 947aedc commit e0c3c4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions OpenAI-DotNet-Tests/TestFixture_03_Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,15 @@ public async Task Test_08_GetChatToolCompletion_Streaming()
Assert.IsNotNull(functionResult);
messages.Add(new Message(usedTool, functionResult));
Console.WriteLine($"{Role.Tool}: {functionResult}");

chatRequest = new ChatRequest(messages, tools: tools, toolChoice: "auto");

response = await OpenAIClient.ChatEndpoint.StreamCompletionAsync(chatRequest, partialResponse =>
{
Assert.IsNotNull(partialResponse);
Assert.NotNull(partialResponse.Choices);
Assert.NotZero(partialResponse.Choices.Count);
});
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion OpenAI-DotNet/Common/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public JsonNode Arguments
if (arguments == null &&
!string.IsNullOrWhiteSpace(argumentsString))
{
arguments = JsonNode.Parse(argumentsString);
arguments = JsonValue.Create(argumentsString);
}

return arguments;
Expand Down

0 comments on commit e0c3c4f

Please sign in to comment.