RageAgainstThePixel / OpenAI-DotNet

A Non-Official OpenAI RESTful API Client for DotNet
https://openai.com
MIT License
690 stars 150 forks source link

'content' is a required property #131

Closed ulfkri closed 1 year ago

ulfkri commented 1 year ago

Bug Report

Overview

When I upload the result of a function call I get this error: 'content' is a required property

To Reproduce

You can reproduce the error by adding these lines to the very end of 'Test_4_GetChatFunctionCompletion':

// Upload result of function call
chatRequest = new ChatRequest(messages, functions: functions, functionCall: "auto", model: "gpt-3.5-turbo-0613");
result = await OpenAIClient.ChatEndpoint.GetCompletionAsync(chatRequest);

Expected behavior

Well, should not crash :)

Additional context

I suppose it's an easy fix to just serialize null to empty string for the 'content' property. In my code I set content to an empty string for all messages that have content == null and that fixes it.

ulfkri commented 1 year ago

We are not supposed to upload the function call, my bad.