Open sdcb opened 4 months ago
Current workaround:
ChatCompletionOptions cco = new ();
cco = ((IJsonModel<ChatCompletionOptions>)cco).Create(new BinaryData("""
{
// this is extra_body content
"enable_search": true
}
"""), ModelReaderWriterOptions.Json);
I presume this is even more relevant now that structured outputs have been added to the API: https://openai.com/index/introducing-structured-outputs-in-the-api/
This would benefit me for a few reasons and allow for faster adoption of new features of this client lags behind the API. I hope this is considered.
In the OpenAI Python SDK, there is an
extra_body
parameter available in theCompletions.create
method, which allows users to add additional JSON properties to the request body. This feature can be very useful in various scenarios, especially when needing to send extra data that is not covered by the predefined parameters.However, this parameter does not exist in the .NET SDK. Including this parameter would help maintain consistency across SDKs and provide .NET users with the same level of flexibility that Python users have.
Reference to Python SDK Code: Here is the implementation in the Python SDK for reference: https://github.com/openai/openai-python/blob/af8f606b3eef1af99f98929847f1b5baf19171ae/src/openai/resources/chat/completions.py#L76
Suggested Change: Add an
extra_body
property to theChatCompletionOptions
class in the .NET SDK that allows additional JSON properties to be serialized into the request body.This could look something like:
Please consider adding this feature to improve the SDK's flexibility and usability.