Skip to content

Commit

Permalink
Merge branch 'feature/net8+newapi' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaPic committed Jan 3, 2024
2 parents 69febf4 + c9e76f7 commit 119a823
Show file tree
Hide file tree
Showing 38 changed files with 2,686 additions and 158 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dotnet-ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
7.0.x
6.0.x
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0.x
7.0.x
6.0.x
- name: Restore dependencies
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,6 @@ MigrationBackup/
FodyWeavers.xsd
*.Development.json
**/launchSettings.json

#Draw.io backup
*.bkp
23 changes: 17 additions & 6 deletions DevExtremeAI/DevExtremeAI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Title>DevExtremeAI is a full and complete implementation of all OpenAI's APIs</Title>
Expand All @@ -12,22 +12,33 @@
<RepositoryUrl>https://github.com/AndreaPic/DevExtremeAI</RepositoryUrl>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Version>$(VersionPrefix)$(VersionSuffix)</Version>
<VersionPrefix>1.1.0</VersionPrefix>
<VersionPrefix>8.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<PackageTags>openai;dotnet;aspnet;csharp;gpt-4;gpt-3.5-turbo;davinci;DALL·E;Whisper;fine-tunes</PackageTags>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<FileVersion>8.0.0.0</FileVersion>
<RepositoryType>git</RepositoryType>
<Description>This library is full compliant to openAI specs and also implement openAI error response. It's very easy to use with asp.net core, has full support to dependency injection and it's very easy to use in libraries without dependency injection.</Description>
<PackageIcon></PackageIcon>
<Copyright></Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>
- (1.1.0 new) *** Full functions implementation ***
- (8.0.0 new) *** .net 8 ***
- (8.0.0 new) updated all new openai api, models and object models, deprecated old unsupported api
- (1.1.0) *** Full functions implementation ***
- (1.0.4) Added support for multiple stop sequences in completions
</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.34" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.34" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
Expand All @@ -38,7 +49,7 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.1.34" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
Expand Down
6 changes: 6 additions & 0 deletions DevExtremeAI/OpenAIClient/OpenAIAPIClient.Completions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
namespace DevExtremeAI.OpenAIClient
{

/// <summary>
/// Create Completions
/// </summary>
/// <remarks>
/// These now are Legacy API
/// </remarks>
partial class OpenAIAPIClient
{
/// <summary>
Expand Down
48 changes: 41 additions & 7 deletions DevExtremeAI/OpenAIClient/OpenAIAPIClient.FineTune.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

namespace DevExtremeAI.OpenAIClient
{

/// <summary>
/// Manage Fine Tuning API
/// </summary>
/// <remarks>
/// The Fine-tunes endpoint will be shut off on January 4th, 2024.
/// </remarks>
partial class OpenAIAPIClient
{
/// <summary>
Expand All @@ -28,7 +33,7 @@ public async Task<ResponseDTO<FineTuneData>> CreateFineTuneJobAsync(CreateFineTu

var jsonContent = CreateJsonStringContent(request);

var httpResponse = await httpClient.PostAsync($"fine-tunes", jsonContent);
var httpResponse = await httpClient.PostAsync($"fine_tuning/jobs", jsonContent);
if (httpResponse.IsSuccessStatusCode)
{
ret.OpenAIResponse = await httpResponse.Content.ReadFromJsonAsync<FineTuneData>();
Expand All @@ -51,9 +56,19 @@ public async Task<ResponseDTO<FineTuneData>> CreateFineTuneJobAsync(CreateFineTu
/// <summary>
/// List your organization's fine-tuning jobs
/// </summary>
/// <param name="request">DTO with request specs.</param>
/// <returns>OpenAIResponse property contains the AI response, if an error occurs HasError is true and the Error property contains the complete error details.</returns>
public async Task<ResponseDTO<GetFineTuneListResponse>> GetFineTuneJobListAsync()
{
return await GetFineTuneJobListAsync(null, null);
}

/// <summary>
/// List your organization's fine-tuning jobs
/// </summary>
/// <param name="after">Identifier for the last job from the previous pagination request.(Optional)</param>
/// <param name="limit">Number of fine-tuning jobs to retrieve.(Optional Default 20)</param>
/// <returns>OpenAIResponse property contains the AI response, if an error occurs HasError is true and the Error property contains the complete error details.</returns>
public async Task<ResponseDTO<GetFineTuneListResponse>> GetFineTuneJobListAsync(string after, int? limit)
{
ResponseDTO<GetFineTuneListResponse> ret = new ResponseDTO<GetFineTuneListResponse>();
HttpClient httpClient = CreateHttpClient(out bool doDispose);
Expand All @@ -62,7 +77,25 @@ public async Task<ResponseDTO<GetFineTuneListResponse>> GetFineTuneJobListAsync(
FillBaseAddress(httpClient);
FillAuthRequestHeaders(httpClient.DefaultRequestHeaders);

var httpResponse = await httpClient.GetAsync($"fine-tunes");
string request = "fine_tuning/jobs";
if (!string.IsNullOrEmpty(after) || limit.HasValue)
{
request += "?" ;
if (!string.IsNullOrEmpty(after))
{
request += $"after={after}" ;
}
if (!string.IsNullOrEmpty(after) && limit.HasValue)
{
request += "&";
}
if (limit.HasValue)
{
request += $"limit={limit}";
}
}

var httpResponse = await httpClient.GetAsync(request);
if (httpResponse.IsSuccessStatusCode)
{
ret.OpenAIResponse = await httpResponse.Content.ReadFromJsonAsync<GetFineTuneListResponse>();
Expand All @@ -82,6 +115,7 @@ public async Task<ResponseDTO<GetFineTuneListResponse>> GetFineTuneJobListAsync(
}
}


/// <summary>
/// Gets info about the fine-tune job.
/// </summary>
Expand All @@ -96,7 +130,7 @@ public async Task<ResponseDTO<FineTuneData>> GetFineTuneJobDataAsync(FineTuneReq
FillBaseAddress(httpClient);
FillAuthRequestHeaders(httpClient.DefaultRequestHeaders);

var httpResponse = await httpClient.GetAsync($"fine-tunes/{request.FineTuneId}");
var httpResponse = await httpClient.GetAsync($"fine_tuning/jobs/{request.FineTuneId}");
if (httpResponse.IsSuccessStatusCode)
{
ret.OpenAIResponse = await httpResponse.Content.ReadFromJsonAsync<FineTuneData>();
Expand Down Expand Up @@ -130,7 +164,7 @@ public async Task<ResponseDTO<FineTuneData>> CancelFineTuneJobAsync(FineTuneRequ
FillBaseAddress(httpClient);
FillAuthRequestHeaders(httpClient.DefaultRequestHeaders);

var httpResponse = await httpClient.PostAsync($"fine-tunes/{request.FineTuneId}/cancel",null);
var httpResponse = await httpClient.PostAsync($"fine_tuning/jobs/{request.FineTuneId}/cancel",null);
if (httpResponse.IsSuccessStatusCode)
{
ret.OpenAIResponse = await httpResponse.Content.ReadFromJsonAsync<FineTuneData>();
Expand Down Expand Up @@ -165,7 +199,7 @@ public async Task<ResponseDTO<GetFineTuneEventListResponse>> GetFineTuneEventLis
FillBaseAddress(httpClient);
FillAuthRequestHeaders(httpClient.DefaultRequestHeaders);

var httpResponse = await httpClient.GetAsync($"fine-tunes/{request.FineTuneId}/events");
var httpResponse = await httpClient.GetAsync($"fine_tuning/jobs/{request.FineTuneId}/events");
if (httpResponse.IsSuccessStatusCode)
{
ret.OpenAIResponse = await httpResponse.Content.ReadFromJsonAsync<GetFineTuneEventListResponse>();
Expand Down
Loading

0 comments on commit 119a823

Please sign in to comment.