Skip to content

Commit

Permalink
Add generated full client for OpenAI and Azure API
Browse files Browse the repository at this point in the history
  • Loading branch information
rodion-m committed Nov 17, 2023
1 parent 3beb4e1 commit 4a5cfdb
Show file tree
Hide file tree
Showing 340 changed files with 22,665 additions and 2 deletions.
7 changes: 7 additions & 0 deletions OpenAI_DotNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{130D40E9-8E3
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "internal", "internal", "{B28033FF-A6F3-48AC-824F-99996B1AC85E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAI.GeneratedKiotaClient", "src\internal\OpenAI.GeneratedKiotaClient\OpenAI.GeneratedKiotaClient.csproj", "{095A8BD6-7B1F-4FB3-AD9E-2B98B138190B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -96,6 +98,10 @@ Global
{F2968A66-5672-439E-823E-D35100CA067D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2968A66-5672-439E-823E-D35100CA067D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2968A66-5672-439E-823E-D35100CA067D}.Release|Any CPU.Build.0 = Release|Any CPU
{095A8BD6-7B1F-4FB3-AD9E-2B98B138190B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{095A8BD6-7B1F-4FB3-AD9E-2B98B138190B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{095A8BD6-7B1F-4FB3-AD9E-2B98B138190B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{095A8BD6-7B1F-4FB3-AD9E-2B98B138190B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -115,5 +121,6 @@ Global
{DB6D8BCB-F003-4624-9277-3B4E1B7CDBCD} = {130D40E9-8E33-4EBA-8AE1-8B9479BC286A}
{068E9E67-C2FC-4F8C-B27C-CB3A8FA44BD8} = {130D40E9-8E33-4EBA-8AE1-8B9479BC286A}
{B28033FF-A6F3-48AC-824F-99996B1AC85E} = {130D40E9-8E33-4EBA-8AE1-8B9479BC286A}
{095A8BD6-7B1F-4FB3-AD9E-2B98B138190B} = {B28033FF-A6F3-48AC-824F-99996B1AC85E}
EndGlobalSection
EndGlobal
3 changes: 1 addition & 2 deletions src/OpenAI.ChatGpt/AzureOpenAiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class AzureOpenAiClient : OpenAiClient
private readonly string _apiVersion;
private const string DefaultApiVersion = "2023-12-01-preview";

//https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference

/// <summary>
/// Creates Azure OpenAI services client
/// </summary>
Expand All @@ -23,6 +21,7 @@ public class AzureOpenAiClient : OpenAiClient
/// <param name="apiVersion">Azure OpenAI API version</param>
/// <remarks>
/// See currently available API versions: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#completions
/// Specifications: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference
/// </remarks>
public AzureOpenAiClient(
string endpointUrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using OpenAI.Azure.GeneratedKiotaClient;

namespace OpenAI.GeneratedKiotaClient;

internal static class GeneratedClientsFactory
{
public static GeneratedOpenAiClient CreateGeneratedOpenAiClient(HttpClient httpClient)
{
ArgumentNullException.ThrowIfNull(httpClient);
var authProvider = new AnonymousAuthenticationProvider();
var adapter = new HttpClientRequestAdapter(authProvider, httpClient: httpClient);
return new GeneratedOpenAiClient(adapter);
}

public static GeneratedAzureOpenAiClient CreateGeneratedAzureOpenAiClient(HttpClient httpClient)
{
ArgumentNullException.ThrowIfNull(httpClient);
var authProvider = new AnonymousAuthenticationProvider();
var adapter = new HttpClientRequestAdapter(authProvider, httpClient: httpClient);
return new GeneratedAzureOpenAiClient(adapter);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<NoWarn>$(NoWarn);CS0618</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.7.2" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.3.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="OpenAI.ChatGpt" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// <auto-generated/>
using Microsoft.Kiota.Abstractions;
using OpenAI.Azure.GeneratedKiotaClient.Deployments.Item;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System;
namespace OpenAI.Azure.GeneratedKiotaClient.Deployments {
/// <summary>
/// Builds and executes requests for operations under \deployments
/// </summary>
internal class DeploymentsRequestBuilder : BaseRequestBuilder {
/// <summary>Gets an item from the OpenAI.Azure.GeneratedKiotaClient.deployments.item collection</summary>
/// <param name="position">Unique identifier of the item</param>
public DeploymentItemRequestBuilder this[string position] { get {
var urlTplParams = new Dictionary<string, object>(PathParameters);
urlTplParams.Add("deployment%2Did", position);
return new DeploymentItemRequestBuilder(urlTplParams, RequestAdapter);
} }
/// <summary>
/// Instantiates a new DeploymentsRequestBuilder and sets the default values.
/// </summary>
/// <param name="pathParameters">Path parameters for the request</param>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public DeploymentsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/deployments", pathParameters) {
}
/// <summary>
/// Instantiates a new DeploymentsRequestBuilder and sets the default values.
/// </summary>
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public DeploymentsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/deployments", rawUrl) {
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// <auto-generated/>
using Microsoft.Kiota.Abstractions;
using OpenAI.Azure.GeneratedKiotaClient.Deployments.Item.Audio.Transcriptions;
using OpenAI.Azure.GeneratedKiotaClient.Deployments.Item.Audio.Translations;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System;
namespace OpenAI.Azure.GeneratedKiotaClient.Deployments.Item.Audio {
/// <summary>
/// Builds and executes requests for operations under \deployments\{deployment-id}\audio
/// </summary>
internal class AudioRequestBuilder : BaseRequestBuilder {
/// <summary>The transcriptions property</summary>
public TranscriptionsRequestBuilder Transcriptions { get =>
new TranscriptionsRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>The translations property</summary>
public TranslationsRequestBuilder Translations { get =>
new TranslationsRequestBuilder(PathParameters, RequestAdapter);
}
/// <summary>
/// Instantiates a new AudioRequestBuilder and sets the default values.
/// </summary>
/// <param name="pathParameters">Path parameters for the request</param>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public AudioRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/deployments/{deployment%2Did}/audio", pathParameters) {
}
/// <summary>
/// Instantiates a new AudioRequestBuilder and sets the default values.
/// </summary>
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
public AudioRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/deployments/{deployment%2Did}/audio", rawUrl) {
}
}
}

Loading

0 comments on commit 4a5cfdb

Please sign in to comment.