Closed NikolaMorena closed 1 week ago
Thank you for reaching out, @NikolaMorena ! From what I have seen, this error can happen when the function calling API is called incorrectly. Here are a few ideas:
ToolChatMessage
, ChatTool
, ChatToolCall
, and ChatToolChoice
. FunctionChatMessage
, ChatFunction
, ChatFunctionCall
, and ChatFunctionChoice
. I will close this issue for now. Let us know if you're still having issues. Thank you!
Confirm this is not an issue with the underlying OpenAI API
Confirm this is not an issue with Azure OpenAI
Describe the bug
The .Net CompleteChat requests that include tools and have name field set for the assistant messages produce "The model produced invalid content" response in 20-30% of the cases.
To Reproduce
Start with official example https://github.com/openai/openai-dotnet?tab=readme-ov-file#how-to-use-chat-completions-with-tools-and-function-calling . Ensure it works as expected for you. Modify the example by setting ParticipantName for each AssistantChatMessage before adding it to the messages list. Ask for the weather 10-20 times. In 20-30% of the cases, the API call fails with the following message: "The model produced invalid content. Consider modifying your prompt if you are seeing this error persistently."
Code snippets
OS
winOs
.NET version
.Net 8.0
Library version
2.0.0.-beta.8