Skip to content

Commit

Permalink
OpenAI-DotNet 6.5.0 (RageAgainstThePixel#70)
Browse files Browse the repository at this point in the history
- Marked EditEndpoint Obsolete as codex and edit models have been removed
  • Loading branch information
StephenHodgson committed Mar 26, 2023
1 parent ac9d263 commit 4b01d8c
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 38 deletions.
29 changes: 20 additions & 9 deletions OpenAI-DotNet-Tests/TestFixture_04_Edits.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
using NUnit.Framework;
using OpenAI.Edits;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace OpenAI.Tests
{
internal class TestFixture_04_Edits : AbstractTestFixture
[Obsolete]
internal class TestFixture_04_Edits
{
[Test]
public async Task Test_1_GetBasicEdit()
{
Assert.IsNotNull(OpenAIClient.EditsEndpoint);
var request = new EditRequest("What day of the wek is it?", "Fix the spelling mistakes");
var result = await OpenAIClient.EditsEndpoint.CreateEditAsync(request);
Assert.IsNotNull(result);
Assert.NotNull(result.Choices);
Assert.NotZero(result.Choices.Count);
Console.WriteLine(result);
Assert.IsTrue(result.ToString().Contains("week"));
var api = new OpenAIClient(OpenAIAuthentication.LoadFromEnv());
Assert.IsNotNull(api.EditsEndpoint);
EditResponse result = null;

try
{
var request = new EditRequest("What day of the wek is it?", "Fix the spelling mistakes");
result = await api.EditsEndpoint.CreateEditAsync(request);
}
catch (HttpRequestException)
{
Assert.IsNull(result);
}
catch (Exception e)
{
Assert.IsTrue(false, $"Expected exception {nameof(HttpRequestException)} but got {e.GetType().Name}");
}
}
}
}
4 changes: 3 additions & 1 deletion OpenAI-DotNet/Edits/Choice.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Text.Json.Serialization;
using System;
using System.Text.Json.Serialization;

namespace OpenAI.Edits
{
[Obsolete]
public sealed class Choice
{
[JsonInclude]
Expand Down
5 changes: 3 additions & 2 deletions OpenAI-DotNet/Edits/EditRequest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using OpenAI.Models;
using System;
using System.Text.Json.Serialization;
using OpenAI.Models;

namespace OpenAI.Edits
{
[Obsolete]
public sealed class EditRequest
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions OpenAI-DotNet/Edits/EditResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace OpenAI.Edits
{
[Obsolete]
public sealed class EditResponse : BaseResponse
{
[JsonInclude]
Expand Down
2 changes: 2 additions & 0 deletions OpenAI-DotNet/Edits/EditsEndpoint.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenAI.Models;
using System;
using System.Text.Json;
using System.Threading.Tasks;

Expand All @@ -8,6 +9,7 @@ namespace OpenAI.Edits
/// Given a prompt and an instruction, the model will return an edited version of the prompt.<br/>
/// <see href="https://beta.openai.com/docs/api-reference/edits"/>
/// </summary>
[Obsolete("Models removed by OpenAI")]
public sealed class EditsEndpoint : BaseEndPoint
{
/// <inheritdoc />
Expand Down
51 changes: 27 additions & 24 deletions OpenAI-DotNet/OpenAI-DotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,84 +17,87 @@ More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet-
<RepositoryUrl>https://github.com/RageAgainstThePixel/OpenAI-DotNet</RepositoryUrl>
<PackageTags>OpenAI, AI, ML, API, gpt-4, gpt-3.5-tubo, gpt-3, chatGPT, chat-gpt, gpt-2, gpt</PackageTags>
<Title>OpenAI API</Title>
<PackageReleaseNotes>Bump version to 6.4.3
<PackageReleaseNotes>Version 6.5.0
- Marked EditEndpoint Obsolete as codex and edit models have been removed
Version 6.4.3
- Fixed support for Azure Active Directory authentication for Azure OpenAI
Bump version to 6.4.2
Version 6.4.2
- Misc fixes and added validation for OpenAICLientSettings
- Updated docs
- Decoupled proxy version from main package
Bump version to 6.4.1
Version 6.4.1
- Added ImageEditRequest overloads for optional mask parameter
Bump version to 6.4.0
Version 6.4.0
- Moved OpenAI-DotNet-Proxy back into its own project and package
- Make a few classes sealed that are not meant to be extended
Bump version to 6.3.2
Version 6.3.2
- Attempt to fix dependency requirement for dotnet/runtime docker base images
- Made internal OpenAIClient constructor with HttpClient public
- Make sure we only copy the appropriate headers in the proxy
Bump version to 6.3.1
Version 6.3.1
- Fixed apikey requiring sk- prefix with Azure OpenAI
Bump version to 6.3.0
Version 6.3.0
- Removed OpenAI-DotNet-Proxy and put it directly in package on its own
Bump version to 6.2.0
Version 6.2.0
- Added OpenAI-DotNet-Proxy project and package.
- Added support for custom domains
- Updated unit tests
- Updated docs
Bump version to 6.1.0
Version 6.1.0
- Added support for gpt-4 models
Bump version to 6.0.1
Version 6.0.1
- Updated package info
- Updated docs
Bump version to 6.0.0
Version 6.0.0
- Added support for Azure OpenAI
Bump version to 5.1.2
Version 5.1.2
- Fixed an issue when deleting personal account fine tuned models
Bump version to 5.1.1
Version 5.1.1
- Refactored Model validation
- Added additional default models
- Deprecate OpenAIClient.DefaultModel
- Implemented chat completion streaming
- Refactored immutable types
Bump version to 5.1.0
Version 5.1.0
- Add support for Audio endpoint and Whisper models
- Audio Speech to text
- Audio translation
Bump version to 5.0.2
Version 5.0.2
- Support multiple inputs in embedding
- Added better model validation in all endpoints
Bump version to 5.0.1
Version 5.0.1
- Fixed chat parameters
Bump version to 5.0.0
Version 5.0.0
- Added Chat endpoint
Bump version to 4.4.4
Version 4.4.4
- ImageEditRequest mask is now optional so long as texture has alpha transparency
- ImageVariationRequest added constructor overload for memory stream image
- Updated AuthInfo parameter validation
- Renamed OPEN_AI_ORGANIZATION_ID -&gt; OPENAI_ORGANIZATION_ID
Bump version to 4.4.3
Version 4.4.3
- added OPEN_AI_ORGANIZATION_ID environment variable
- deprecated Organization use OrganizationId instead
Bump version to 4.4.2
Version 4.4.2
- Removed a useless assert
- Updated docs
Bump version to 4.4.1
Version 4.4.1
- hotfix to CompletionsEndpoint to use IEnumerable&lt;string&gt;
- hotfix to cleanup Images endpoints
Bump version to 4.4.0
Version 4.4.0
- Renamed Choice.Logprobs -&gt; Choice.LogProbabilities
- Renamed OpenAI.Completions.Logprobs -&gt; OpenAI.Completions.OpenAI.Completions
- Renamed CompletionRequest parameter names:
- max_tokens -&gt; maxTokens
- top_p -&gt; topP
- Updated CompletionRequest to accept IEnumerable&lt;string&gt; values for prompts and stopSequences
- Refactored all endpoints to use new response validation extension
- Added CancellationToken to most endpoints that had long running operations</PackageReleaseNotes>
- Added CancellationToken to most endpoints that had long running operations
</PackageReleaseNotes>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>OpenAI-DotNet.pfx</AssemblyOriginatorKeyFile>
<DelaySign>true</DelaySign>
<PackageId>OpenAI-DotNet</PackageId>
<Version>6.4.3</Version>
<Version>6.5.0</Version>
<Company>RageAgainstThePixel</Company>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>Assets\OpenAI-DotNet-Icon.png</PackageIcon>
Expand Down
4 changes: 4 additions & 0 deletions OpenAI-DotNet/OpenAIClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OpenAI.Images;
using OpenAI.Models;
using OpenAI.Moderations;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Authentication;
Expand Down Expand Up @@ -70,7 +71,9 @@ public OpenAIClient(OpenAIAuthentication openAIAuthentication = null, OpenAIClie
ModelsEndpoint = new ModelsEndpoint(this);
CompletionsEndpoint = new CompletionsEndpoint(this);
ChatEndpoint = new ChatEndpoint(this);
#pragma warning disable CS0618
EditsEndpoint = new EditsEndpoint(this);
#pragma warning restore CS0618
ImagesEndPoint = new ImagesEndpoint(this);
EmbeddingsEndpoint = new EmbeddingsEndpoint(this);
AudioEndpoint = new AudioEndpoint(this);
Expand Down Expand Up @@ -156,6 +159,7 @@ private HttpClient SetupClient(HttpClient client = null)
/// Given a prompt and an instruction, the model will return an edited version of the prompt.<br/>
/// <see href="https://beta.openai.com/docs/api-reference/edits"/>
/// </summary>
[Obsolete("Models removed by OpenAI")]
public EditsEndpoint EditsEndpoint { get; }

/// <summary>
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Install-Package OpenAI-DotNet
- [Chat](#chat)
- [Chat Completions](#chat-completions)
- [Streaming](#chat-streaming)
- [Edits](#edits)
- [Create Edit](#create-edit)
- [Edits](#edits) :warning:
- [Create Edit](#create-edit) :warning:
- [Embeddings](#embeddings)
- [Create Embedding](#create-embeddings)
- [Audio](#audio)
Expand Down Expand Up @@ -381,6 +381,10 @@ await foreach (var result in api.ChatEndpoint.StreamCompletionEnumerableAsync(ch

### [Edits](https://beta.openai.com/docs/api-reference/edits)

> :warning: The models for this endpoint have been removed making it no longer usable.
>
> [See forum post for more details](https://community.openai.com/t/the-model-text-davinci-edit-001-does-not-exist/116144).
Given a prompt and an instruction, the model will return an edited version of the prompt.

The Edits API is accessed via `OpenAIClient.EditsEndpoint`
Expand Down

0 comments on commit 4b01d8c

Please sign in to comment.