diff --git a/.dotnet/aoai/AzureOpenAI/AzureChatClient.cs b/.dotnet/aoai/AzureOpenAI/AzureChatClient.cs new file mode 100644 index 000000000..744f21fc2 --- /dev/null +++ b/.dotnet/aoai/AzureOpenAI/AzureChatClient.cs @@ -0,0 +1,18 @@ +using OpenAI; +using OpenAI.Chat; +using System.ClientModel; +using System.ClientModel.Primitives; + +namespace AzureOpenAI; + +internal class AzureChatClient : ChatClient +{ + public AzureChatClient(string model, ApiKeyCredential? credential = null, OpenAIClientOptions? options = null) + : base(model, credential, options) + { + } + + protected override PipelineMessage CreateCustomRequestMessage(IEnumerable messages, int? choiceCount, ChatCompletionOptions options) + { + } +} diff --git a/.dotnet/aoai/AzureOpenAI/AzureOpenAI.csproj b/.dotnet/aoai/AzureOpenAI/AzureOpenAI.csproj new file mode 100644 index 000000000..8fe75562b --- /dev/null +++ b/.dotnet/aoai/AzureOpenAI/AzureOpenAI.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/.dotnet/aoai/AzureOpenAI/AzureOpenAIClient.cs b/.dotnet/aoai/AzureOpenAI/AzureOpenAIClient.cs new file mode 100644 index 000000000..9ccd60420 --- /dev/null +++ b/.dotnet/aoai/AzureOpenAI/AzureOpenAIClient.cs @@ -0,0 +1,28 @@ +using OpenAI; +using OpenAI.Chat; +using System.ClientModel; + +namespace AzureOpenAI; + +public class AzureOpenAIClient : OpenAIClient +{ + private readonly Uri _endpoint; + + private readonly ApiKeyCredential _keyCredential; + private readonly OpenAIClientOptions _unbrandedClientOptions; + + public AzureOpenAIClient(Uri endpoint, ApiKeyCredential credential, AzureOpenAIClientOptions? options = default) + { + options ??= new(); + + _endpoint = endpoint; + _keyCredential = credential; + + _unbrandedClientOptions = options.ToOpenAIClientOptions(); + } + + public override ChatClient GetChatClient(string model) + { + return new AzureChatClient(model, _keyCredential, _unbrandedClientOptions); + } +} diff --git a/.dotnet/aoai/AzureOpenAI/AzureOpenAIClientOptions.cs b/.dotnet/aoai/AzureOpenAI/AzureOpenAIClientOptions.cs new file mode 100644 index 000000000..c7e593678 --- /dev/null +++ b/.dotnet/aoai/AzureOpenAI/AzureOpenAIClientOptions.cs @@ -0,0 +1,7 @@ +using System.ClientModel.Primitives; + +namespace AzureOpenAI; + +public class AzureOpenAIClientOptions : ClientPipelineOptions +{ +} diff --git a/.dotnet/aoai/AzureOpenAI/AzureOpenAIExtensions.cs b/.dotnet/aoai/AzureOpenAI/AzureOpenAIExtensions.cs new file mode 100644 index 000000000..1d7c76077 --- /dev/null +++ b/.dotnet/aoai/AzureOpenAI/AzureOpenAIExtensions.cs @@ -0,0 +1,11 @@ +using OpenAI; + +namespace AzureOpenAI; + +internal static class AzureOpenAIExtensions +{ + public static OpenAIClientOptions ToOpenAIClientOptions(this AzureOpenAIClientOptions options) + { + throw new NotImplementedException(); + } +} diff --git a/.dotnet/src/Custom/Chat/ChatClient.cs b/.dotnet/src/Custom/Chat/ChatClient.cs index e8ae289a7..0f42154b4 100644 --- a/.dotnet/src/Custom/Chat/ChatClient.cs +++ b/.dotnet/src/Custom/Chat/ChatClient.cs @@ -190,7 +190,6 @@ public virtual Task> CompleteChatStre /// The number of independent, alternative choices that the chat completion request should generate. /// /// Additional options for the chat completion request. - /// The cancellation token for the operation. /// A streaming result with incremental chat completion updates. public virtual StreamingClientResult CompleteChatStreaming( IEnumerable messages, @@ -228,7 +227,6 @@ public virtual StreamingClientResult CompleteChatStreaming( /// The number of independent, alternative choices that the chat completion request should generate. /// /// Additional options for the chat completion request. - /// The cancellation token for the operation. /// A streaming result with incremental chat completion updates. public virtual async Task> CompleteChatStreamingAsync( IEnumerable messages, @@ -301,7 +299,14 @@ private Internal.Models.CreateChatCompletionRequest CreateInternalRequest( ); } - private PipelineMessage CreateCustomRequestMessage(IEnumerable messages, int? choiceCount, ChatCompletionOptions options) + /// + /// TBD. + /// + /// + /// + /// + /// + protected virtual PipelineMessage CreateCustomRequestMessage(IEnumerable messages, int? choiceCount, ChatCompletionOptions options) { Internal.Models.CreateChatCompletionRequest internalRequest = CreateInternalRequest(messages, options, choiceCount, stream: true); BinaryContent content = BinaryContent.Create(internalRequest); diff --git a/.dotnet/src/Custom/OpenAIClient.cs b/.dotnet/src/Custom/OpenAIClient.cs index cd2219a0b..e14cf4d8f 100644 --- a/.dotnet/src/Custom/OpenAIClient.cs +++ b/.dotnet/src/Custom/OpenAIClient.cs @@ -5,7 +5,6 @@ using OpenAI.Files; using OpenAI.FineTuningManagement; using OpenAI.Images; -using OpenAI.LegacyCompletions; using OpenAI.ModelManagement; using OpenAI.Moderations; using System.ClientModel; @@ -70,7 +69,7 @@ public OpenAIClient(ApiKeyCredential credential = default, OpenAIClientOptions o /// the same configuration details. /// /// A new . - public ChatClient GetChatClient(string model) => new(model, _cachedCredential, _cachedOptions); + public virtual ChatClient GetChatClient(string model) => new(model, _cachedCredential, _cachedOptions); /// /// Gets a new instance of that reuses the client configuration details provided to diff --git a/README.md b/README.md deleted file mode 100644 index 0f9e25d5f..000000000 --- a/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# A conversion of the OpenAI OpenAPI to TypeSpec - -Snapshot: https://raw.githubusercontent.com/openai/openai-openapi/28a300c5784415af66f81b2acc0db182f6eb3bbd/openapi.yaml - -There are some deltas: - -### Changes to API Semantics - -- Many things are missing defaults (mostly due to bug where we can't set null defaults) -- Error responses have been added. -- Where known, the `object` property's type is narrowed from string to the constant value it will always be - -### Changes to API metadata or OpenAPI format - -- Much of the x-oaiMeta entries have not been added. -- In some cases, new schemas needed to be defined in order to be defined in TypeSpec (e.g. because the constraints could not be added to a model property with a heterogeneous type) -- There is presently no way to set `title`