Closed Swah closed 2 months ago
Just adding that using function calls seems to work (see https://github.com/openai/openai-dotnet/issues/193)
private ChatTool GetSchema<T>() => ChatTool.CreateFunctionTool(
functionName: nameof(T),
functionDescription: "This is a format to create novel charater which user wants.",
functionParameters: BinaryData.FromString(CreateSchema<T>()));
ChatCompletionOptions options = new()
{
Tools = { GetSchema<T>() },
ToolChoice = ChatToolChoice.Required,
};
client.CompleteChatAsync(new List<UserChatMessage> { chatMessage }, options)
So the issue could potentially be with ChatResponseFormat.CreateJsonSchemaFormat, or with how chat responses are handled internally compared to function calls. It seems like using Unity / C# 9.0 could be involved as well.
Thank you for reaching out, @Swah ! Based on the information that you and @helloSalmon provided here and in the other thread (https://github.com/openai/openai-dotnet/issues/193), we were able to identify the issue and track it back to this issue in the .NET runtime: π https://github.com/dotnet/runtime/issues/103365.
I implemented a mitigation as part of this PR: π https://github.com/openai/openai-dotnet/pull/206. I confirmed that this fixes the problem in Unity. ChatResponseFormat
works as expected now.
We also just pushed a release today, so you can go grab this fix starting with version 2.0.0-beta.11: π https://www.nuget.org/packages/OpenAI/2.0.0-beta.11
@joseharriaga that was one of the quickest resolution on a ticket I've experienced, thanks :)
I can confirm beta.11 seems to fix the issue for me, using chat completion instead of function calls. Thanks again!
Confirm this is not an issue with the OpenAI Python Library
Confirm this is not an issue with the underlying OpenAI API
Confirm this is not an issue with Azure OpenAI
Describe the bug
I'm always getting the same error message as soon as I try to use any variation of ChatResponseFormat.CreateJsonSchemaFormat
In the code below, if I use
chatOptions.ResponseFormat = ChatResponseFormat.JsonObject
, I don't get an error message, but then I of course don't get to specify the schema.This user was also having issues in Unity, but the error message was unclear so it's hard to know if it's the same issue. Plus whatever fixed it should be documented.
To Reproduce
Run the code below in Unity 2022.3.22f1 Library installed using NuGet for Unity
Code snippets
OS
winOS
.NET version
.NET Standard 2.1
Library version
2.0.0-beta.10