Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,75 @@
# Release History

## 2.0.0-beta.7 (Unreleased)
## 2.0.0-beta.8 (Unreleased)

## Bugs Fixed
### Features Added

### Breaking Changes

### Bugs Fixed

- ([#49](https://github.com/openai/openai-dotnet/issues/49)) Fixed a bug with extensible enums implementing case-insensitive equality but case-sensitive hash codes. (commit_hash)
- ([#57](https://github.com/openai/openai-dotnet/issues/57)) Fixed a bug with requests URIs with query string parameter potentially containing a malformed double question mark (`??`) on .NET Framework (net481).

- ([#84](https://github.com/openai/openai-dotnet/issues/84)) Fixed a `NullReferenceException` thrown when adding the custom headers policy while `OpenAIClientOptions` is null (commit_hash)
### Other Changes

## 2.0.0-beta.7 (2024-06-24)

### Bugs Fixed

- ([#84](https://github.com/openai/openai-dotnet/issues/84)) Fixed a `NullReferenceException` thrown when adding the custom headers policy while `OpenAIClientOptions` is null ([0b97311](https://github.com/openai/openai-dotnet/commit/0b97311f58dfb28bd883d990f68d548da040a807))

## 2.0.0-beta.6 (2024-06-21)

## Features Added
### Features Added

- `OrganizationId` and `ProjectId` are now present on `OpenAIClientOptions`. When instantiating a client, providing an instance of `OpenAIClientOptions` with these properties set will cause the client to add the appropriate request headers for org/project, eliminating the need to manually configure the headers. ([9ee7dff](https://github.com/openai/openai-dotnet/commit/9ee7dff064a9412c069a793ff62096b8db4aa43d))

## Bugs Fixed
### Bugs Fixed

- ([#72](https://github.com/openai/openai-dotnet/issues/72)) Fixed `filename` request encoding in operations using `multipart/form-data`, including `files` and `audio` ([2ba8e69](https://github.com/openai/openai-dotnet/commit/2ba8e69512e187ea0b761edda8bce2cd5c79c58a))
- ([#79](https://github.com/openai/openai-dotnet/issues/79)) Fixed hard-coded `user` role for caller-created Assistants API messages on threads ([d665b61](https://github.com/openai/openai-dotnet/commit/d665b61fc7ef1ada00a8ef5c00d1a47d276be032))
- Fixed non-streaming Assistants API run step details not reporting code interpreter logs when present ([d665b61](https://github.com/openai/openai-dotnet/commit/d665b61fc7ef1ada00a8ef5c00d1a47d276be032))

## Breaking Changes
### Breaking Changes

**Assistants (beta)**:

- `AssistantClient.CreateMessage()` and the explicit constructor for `ThreadInitializationMessage` now require a `MessageRole` parameter. This properly enables the ability to create an Assistant message representing conversation history on a new thread. ([d665b61](https://github.com/openai/openai-dotnet/commit/d665b61fc7ef1ada00a8ef5c00d1a47d276be032))

## 2.0.0-beta.5 (2024-06-14)

## Features Added
### Features Added

- API updates, current to [openai/openai-openapi@dd73070b](https://github.com/openai/openai-openapi/commit/dd73070b1d507645d24c249a63ebebd3ec38c0cb) ([1af6569](https://github.com/openai/openai-dotnet/commit/1af6569e2ceae9d840b8826e42d7e3b2569b43f6))
- This includes `MaxResults` for Assistants `FileSearchToolDefinition`, `ParallelToolCallsEnabled` for function tools in Assistants and Chat, and `FileChunkingStrategy` for Assistants VectorStores
- Optional `CancellationToken` parameters are now directly present on most methods, eliminating the need to use protocol methods ([19a65a0](https://github.com/openai/openai-dotnet/commit/19a65a0a943fa3bef1ec8504708aaa526a1ee03a))

## Bugs Fixed
### Bugs Fixed

- ([#30](https://github.com/openai/openai-dotnet/issues/30)) Mitigated a .NET runtime issue that prevented chat message content and several other types from serializing correct on targets including mono and wasm ([896b9e0](https://github.com/openai/openai-dotnet/commit/896b9e0bc60f0ace90bd0d1af1254cf2680f8df6))
- Assistants: Fixed an issue that threw an exception when receiving code interpreter run step logs when streaming a run ([207d597](https://github.com/openai/openai-dotnet/commit/207d59762e7eeb666b7ab2728a0bbee7c0cdd918))
- Fixed a concurrency condition that could cause `multipart/form-data` requests to no longer generate random content part boundaries (no direct scenario impact) ([7cacdee](https://github.com/openai/openai-dotnet/commit/7cacdee2366df3cfa7e6c43bb050da54d23f8db9))

## Breaking Changes
### Breaking Changes

**Assistants (beta)**:

- `InputQuote` is removed from Assistants `TextAnnotation` and `TextAnnotationUpdate`, per [openai/openai-openapi@dd73070b](https://github.com/openai/openai-openapi/commit/dd73070b1d507645d24c249a63ebebd3ec38c0cb) ([1af6569](https://github.com/openai/openai-dotnet/commit/1af6569e2ceae9d840b8826e42d7e3b2569b43f6))

## Other Changes
### Other Changes

- Added an environment-variable-based test project to the repository with baseline scenario coverage ([db6328a](https://github.com/openai/openai-dotnet/commit/db6328accdd7927f19915cdc5412eb841f2447c1))
- Build/analyzer warnings cleaned up throughout the project ([45fc4d7](https://github.com/openai/openai-dotnet/commit/45fc4d72c12314aea83264ebe2e1dc18870e5c06), [b1fa082](https://github.com/openai/openai-dotnet/commit/b1fa0828a875906ef33ffe43ff1cd1a85fbd1a60), [22ab606](https://github.com/openai/openai-dotnet/commit/22ab606b867bbe0ea7f6918843dbc5e11dfe78eb))
- Proactively aligned library's implementation of server-sent event (SSE) handling with the source of the incoming `System.Net.ServerSentEvents` namespace ([674e0f7](https://github.com/openai/openai-dotnet/commit/674e0f773b26a22eb039e879539c4c7a44fdffdd))

## 2.0.0-beta.4 (2024-06-10)

## Features Added
### Features Added

- Added new, built-in helpers to simplify the use of text-only message content ([1c40de6](https://github.com/openai/openai-dotnet/commit/1c40de673a67ddf834b673aaabb94b2c42076e03))

## Bugs Fixed
### Bugs Fixed

- Optimized embedding deserialization and addressed correctness on big endian systems ([e28b5a7](https://github.com/openai/openai-dotnet/commit/e28b5a7787df4b1baa772406b09a0f650a45c77f))
- Optimized b64_json message parsing via regex ([efd76b5](https://github.com/openai/openai-dotnet/commit/efd76b50f094c585350240aea051ba342c6f6622))
Expand All @@ -81,4 +96,5 @@ This is the official OpenAI client library for C# / .NET. It provides convenient
### Breaking Changes

If you are a user migrating from version 1.11.0 or earlier, we will soon share a migration guide to help you get started.

- ***Addendum:** the [migration guide](https://github.com/openai/openai-dotnet/blob/main/MigrationGuide.md) is now available.*
8 changes: 4 additions & 4 deletions src/Custom/Assistants/Internal/GeneratorStubs.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,13 @@ internal readonly partial struct InternalMessageObjectRole { }
[CodeGenModel("CreateRunRequestModel")]
internal readonly partial struct InternalCreateRunRequestModel { }

[CodeGenModel("CreateRunRequestToolChoice")]
internal readonly partial struct InternalCreateRunRequestToolChoice { }

[CodeGenModel("CreateThreadAndRunRequestModel")]
internal readonly partial struct InternalCreateThreadAndRunRequestModel { }

[CodeGenModel("CreateAssistantRequestResponseFormat")]
[CodeGenModel("CreateAssistantRequestResponseFormat1")]
internal readonly partial struct InternalCreateAssistantRequestResponseFormat { }

[CodeGenModel("CreateAssistantRequestToolResources")]
Expand All @@ -361,9 +364,6 @@ internal partial class InternalCreateAssistantRequestToolResourcesFileSearchVect
[CodeGenModel("CreateAssistantRequestToolResourcesFileSearchVectorStoreIdReferences")]
internal partial class InternalCreateAssistantRequestToolResourcesFileSearchVectorStoreIdReferences { }

[CodeGenModel("CreateThreadAndRunRequestToolChoice")]
internal readonly partial struct InternalCreateThreadAndRunRequestToolChoice { }

[CodeGenModel("CreateThreadAndRunRequestToolResources")]
internal partial class InternalCreateThreadAndRunRequestToolResources { }

Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Audio/AudioTranscriptionFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OpenAI.Audio;
/// <summary>
/// Specifies the format of the audio transcription.
/// </summary>
[CodeGenModel("CreateTranscriptionRequestResponseFormat")]
[CodeGenModel("CreateTranscriptionRequestResponseFormat1")]
public enum AudioTranscriptionFormat
{
/// <summary> Text. </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Custom/Chat/ChatFinishReason.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace OpenAI.Chat;
/// </item>
/// </list>
/// </summary>
[CodeGenModel("CreateChatCompletionResponseChoiceFinishReason")]
[CodeGenModel("CreateChatCompletionResponseChoiceFinishReason1")]
public enum ChatFinishReason
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Generated/AudioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal PipelineMessage CreateCreateTranscriptionRequest(BinaryContent content,
uri.AppendPath("/audio/transcriptions", false);
request.Uri = uri.ToUri();
request.Headers.Set("Accept", "application/json");
request.Headers.Set("content-type", contentType);
request.Headers.Set("Content-Type", contentType);
request.Content = content;
message.Apply(options);
return message;
Expand All @@ -69,7 +69,7 @@ internal PipelineMessage CreateCreateTranslationRequest(BinaryContent content, s
uri.AppendPath("/audio/translations", false);
request.Uri = uri.ToUri();
request.Headers.Set("Accept", "application/json");
request.Headers.Set("content-type", contentType);
request.Headers.Set("Content-Type", contentType);
request.Content = content;
message.Apply(options);
return message;
Expand Down
2 changes: 1 addition & 1 deletion src/Generated/FileClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal PipelineMessage CreateCreateFileRequest(BinaryContent content, string c
uri.AppendPath("/files", false);
request.Uri = uri.ToUri();
request.Headers.Set("Accept", "application/json");
request.Headers.Set("content-type", contentType);
request.Headers.Set("Content-Type", contentType);
request.Content = content;
message.Apply(options);
return message;
Expand Down
4 changes: 2 additions & 2 deletions src/Generated/ImageClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal PipelineMessage CreateCreateImageEditRequest(BinaryContent content, str
uri.AppendPath("/images/edits", false);
request.Uri = uri.ToUri();
request.Headers.Set("Accept", "application/json");
request.Headers.Set("content-type", contentType);
request.Headers.Set("Content-Type", contentType);
request.Content = content;
message.Apply(options);
return message;
Expand All @@ -69,7 +69,7 @@ internal PipelineMessage CreateCreateImageVariationRequest(BinaryContent content
uri.AppendPath("/images/variations", false);
request.Uri = uri.ToUri();
request.Headers.Set("Accept", "application/json");
request.Headers.Set("content-type", contentType);
request.Headers.Set("Content-Type", contentType);
request.Content = content;
message.Apply(options);
return message;
Expand Down
6 changes: 1 addition & 5 deletions src/Generated/Internal/ClientUriBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ public void AppendQuery(string name, string value, bool escape)
Argument.AssertNotNullOrWhiteSpace(name, nameof(name));
Argument.AssertNotNullOrWhiteSpace(value, nameof(value));

if (QueryBuilder.Length == 0)
{
QueryBuilder.Append('?');
}
else
if (QueryBuilder.Length > 0)
{
QueryBuilder.Append('&');
}
Expand Down
2 changes: 0 additions & 2 deletions src/Generated/Models/Assistant.Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ void IJsonModel<Assistant>.Write(Utf8JsonWriter writer, ModelReaderWriterOptions
writer.WriteNull("top_p");
}
}
// CUSTOM: Made nullable.
if (Optional.IsDefined(ResponseFormat))
{
if (ResponseFormat != null)
Expand Down Expand Up @@ -287,7 +286,6 @@ internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderW
topP = property.Value.GetSingle();
continue;
}
// CUSTOM: Made nullable.
if (property.NameEquals("response_format"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ void IJsonModel<AssistantCreationOptions>.Write(Utf8JsonWriter writer, ModelRead
writer.WriteNull("top_p");
}
}
// CUSTOM: Made nullable.
if (Optional.IsDefined(ResponseFormat))
{
if (ResponseFormat != null)
Expand Down Expand Up @@ -281,7 +280,6 @@ internal static AssistantCreationOptions DeserializeAssistantCreationOptions(Jso
topP = property.Value.GetSingle();
continue;
}
// CUSTOM: Made nullable.
if (property.NameEquals("response_format"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ void IJsonModel<AssistantModificationOptions>.Write(Utf8JsonWriter writer, Model
writer.WriteNull("top_p");
}
}
// CUSTOM: Made nullable.
if (Optional.IsDefined(ResponseFormat))
{
if (ResponseFormat != null)
Expand Down Expand Up @@ -284,7 +283,6 @@ internal static AssistantModificationOptions DeserializeAssistantModificationOpt
topP = property.Value.GetSingle();
continue;
}
// CUSTOM: Made nullable.
if (property.NameEquals("response_format"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
Expand Down
11 changes: 9 additions & 2 deletions src/Generated/Models/ChatCompletionOptions.Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,15 @@ void IJsonModel<ChatCompletionOptions>.Write(Utf8JsonWriter writer, ModelReaderW
}
if (Optional.IsCollectionDefined(StopSequences))
{
writer.WritePropertyName("stop"u8);
SerializeStopSequencesValue(writer, options);
if (StopSequences != null)
{
writer.WritePropertyName("stop"u8);
SerializeStopSequencesValue(writer, options);
}
else
{
writer.WriteNull("stop");
}
}
if (Optional.IsDefined(Stream))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Generated/Models/ChatToolCallKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ChatToolCallKind(string value)
public bool Equals(ChatToolCallKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/ChatToolKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ChatToolKind(string value)
public bool Equals(ChatToolKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/FileUploadPurpose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public FileUploadPurpose(string value)
public bool Equals(FileUploadPurpose other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/GeneratedImageSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace OpenAI.Images
public bool Equals(GeneratedImageSize other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ImageChatMessageContentPartDetail(string value)
public bool Equals(ImageChatMessageContentPartDetail other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/InternalAssistantObjectObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public InternalAssistantObjectObject(string value)
public bool Equals(InternalAssistantObjectObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public InternalAssistantToolsFileSearchTypeOnlyType(string value)
public bool Equals(InternalAssistantToolsFileSearchTypeOnlyType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public InternalAssistantsApiResponseFormatType(string value)
public bool Equals(InternalAssistantsApiResponseFormatType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public InternalAssistantsNamedToolChoiceType(string value)
public bool Equals(InternalAssistantsNamedToolChoiceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/InternalBatchCompletionTimeframe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public InternalBatchCompletionTimeframe(string value)
public bool Equals(InternalBatchCompletionTimeframe other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
2 changes: 1 addition & 1 deletion src/Generated/Models/InternalBatchErrorsObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public InternalBatchErrorsObject(string value)
public bool Equals(InternalBatchErrorsObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);

[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0;
public override string ToString() => _value;
}
}
Loading