[API Proposal]: OpenAI ChatCompletionOptions to ChatOptions
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 894
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
### Background and motivation
I'm trying to build an OpenAI proxy. I can deserialize the `ChatCompletionOptions` fine, there is an extension method available to extract the MEAI `ChatMessage` but nothing to extract the `ChatOptions` from it.
### API Proposal
```csharp
namespace OpenAI.Chat;
public static class MicrosoftExtensionsAIChatExtensions
{
public static Microsoft.Extensions.AI.ChatOptions AsChatOptions(this OpenAI.Chat.ChatCompletionOptions options);
}
```
### API Usage
```csharp
[HttpPost("v1/chat/completions")]
public async Task CreateChatCompletion(
[FromBody] OpenAI.Chat.ChatCompletionOptions options,
CancellationToken cancellation)
{
var chatResponse = await _chatClient.GetResponseAsync(
options.Messages.AsChatMessages(),
options.AsChatOptions(),
cancellation);
return chatResponse.ToOpenAIChatCompletion();
}
```
### Alternative Designs
_No response_
### Risks
As you found out last year, the OpenAI library has many properties that are not public https://github.com/openai/openai-dotnet/issues/306.
Contributor guide
Assessment
This issue has not been assessed yet.