Skip to content

Commit e4af169

Browse files
authored
Prepare 2.0.0 release (Part 2) (#234)
1 parent 31c2ba6 commit e4af169

14 files changed

+106
-89
lines changed

CHANGELOG.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
# Release History
22

3-
## 2.0.0-beta.14 (Unreleased)
3+
## 2.0.0 (2024-09-30)
4+
5+
> [!NOTE]
6+
> First stable version of the official OpenAI library for .NET.
7+
8+
### Features Added
9+
10+
- Support for OpenAI's latest flagship models, including GPT-4o, GPT-4o mini, o1-preview, and o1-mini
11+
- Support for the entire OpenAI REST API, including:
12+
- Structured outputs
13+
- Reasoning tokens
14+
- Experimental support for Assistants beta v2
15+
- Support for sync and async APIs
16+
- Convenient APIs to facilitate working with streaming chat completions and assistants
17+
- Tons of other quality-of-life features for ease of use and productivity
418

519
### Breaking Changes
620

7-
- Implemented `ChatMessageContent` to encapsulate the representation of content parts in `ChatMessage`, `ChatCompletion`, and `StreamingChatCompletionUpdate`. (commit_hash)
8-
- Changed the representation of function arguments to `BinaryData` in `ChatToolCall`, `StreamingChatToolCallUpdate`, `ChatFunctionCall`, and `StreamingChatFunctionCallUpdate`. (commit_hash)
9-
- Renamed `OpenAIClientOptions`'s `ApplicationId` to `UserAgentApplicationId` (commit_hash)
10-
- Renamed `StreamingChatToolCallUpdate`'s `Id` to `ToolCallId` (commit_hash)
11-
- Renamed `StreamingChatCompletionUpdate`'s `Id` to `CompletionId` (commit_hash)
12-
- Replaced `Auto` and `None` in the deprecated `ChatFunctionChoice` with `CreateAutoChoice()` and `CreateNoneChoice()` (commit_hash)
13-
- Replaced the deprecated `ChatFunctionChoice(ChatFunction)` constructor with `CreateNamedChoice(string functionName)` (commit_hash)
14-
- Renamed `FileClient` to `OpenAIFileClient` and the corresponding `GetFileClient()` method in `OpenAIClient` to `GetOpenAIFileClient()`. (commit_hash)
15-
- Renamed `ModelClient` to `OpenAIModelClient` and the corresponding `GetModelClient()` method in `OpenAIClient` to `GetOpenAIModelClient()`. (commit_hash)
21+
> [!NOTE]
22+
> The following breaking changes only apply when upgrading from the previous 2.0.0-beta.* versions.
23+
24+
- Implemented `ChatMessageContent` to encapsulate the representation of content parts in `ChatMessage`, `ChatCompletion`, and `StreamingChatCompletionUpdate`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
25+
- Changed the representation of function arguments to `BinaryData` in `ChatToolCall`, `StreamingChatToolCallUpdate`, `ChatFunctionCall`, and `StreamingChatFunctionCallUpdate`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
26+
- Renamed `OpenAIClientOptions`'s `ApplicationId` to `UserAgentApplicationId`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
27+
- Renamed `StreamingChatToolCallUpdate`'s `Id` to `ToolCallId`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
28+
- Renamed `StreamingChatCompletionUpdate`'s `Id` to `CompletionId`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
29+
- Replaced `Auto` and `None` in the deprecated `ChatFunctionChoice` with `CreateAutoChoice()` and `CreateNoneChoice()`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
30+
- Replaced the deprecated `ChatFunctionChoice(ChatFunction)` constructor with `CreateNamedChoice(string functionName)`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
31+
- Renamed `FileClient` to `OpenAIFileClient` and the corresponding `GetFileClient()` method in `OpenAIClient` to `GetOpenAIFileClient()`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
32+
- Renamed `ModelClient` to `OpenAIModelClient` and the corresponding `GetModelClient()` method in `OpenAIClient` to `GetOpenAIModelClient()`. ([31c2ba6](https://github.com/openai/openai-dotnet/commit/31c2ba63c625b1b4fc2640ddf378a97e89b89167))
1633

1734
## 2.0.0-beta.13 (2024-09-27)
1835

README.md

Lines changed: 60 additions & 60 deletions
Large diffs are not rendered by default.

examples/Assistants/Example01_RetrievalAugmentedGeneration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void Example01_RetrievalAugmentedGeneration()
2020
AssistantClient assistantClient = openAIClient.GetAssistantClient();
2121

2222
// First, let's contrive a document we'll use retrieval with and upload it.
23-
using Stream document = BinaryData.FromString("""
23+
using Stream document = BinaryData.FromBytes("""
2424
{
2525
"description": "This document contains the sale history data for Contoso products.",
2626
"sales": [
@@ -47,7 +47,7 @@ public void Example01_RetrievalAugmentedGeneration()
4747
}
4848
]
4949
}
50-
""").ToStream();
50+
"""u8.ToArray()).ToStream();
5151

5252
OpenAIFile salesFile = fileClient.UploadFile(
5353
document,

examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public async Task Example01_RetrievalAugmentedGenerationAsync()
2121
AssistantClient assistantClient = openAIClient.GetAssistantClient();
2222

2323
// First, let's contrive a document we'll use retrieval with and upload it.
24-
using Stream document = BinaryData.FromString("""
24+
using Stream document = BinaryData.FromBytes("""
2525
{
2626
"description": "This document contains the sale history data for Contoso products.",
2727
"sales": [
@@ -48,7 +48,7 @@ public async Task Example01_RetrievalAugmentedGenerationAsync()
4848
}
4949
]
5050
}
51-
""").ToStream();
51+
"""u8.ToArray()).ToStream();
5252

5353
OpenAIFile salesFile = await fileClient.UploadFileAsync(
5454
document,

examples/Assistants/Example05_AssistantsWithVision.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ public void Example05_AssistantsWithVision()
1919
AssistantClient assistantClient = openAIClient.GetAssistantClient();
2020

2121
OpenAIFile pictureOfAppleFile = fileClient.UploadFile(
22-
Path.Combine("Assets", "picture-of-apple.png"),
22+
Path.Combine("Assets", "images_apple.png"),
2323
FileUploadPurpose.Vision);
24-
Uri linkToPictureOfOrange = new("https://raw.githubusercontent.com/openai/openai-dotnet/refs/heads/main/examples/Assets/picture-of-orange.png");
24+
25+
Uri linkToPictureOfOrange = new("https://raw.githubusercontent.com/openai/openai-dotnet/refs/heads/main/examples/Assets/images_orange.png");
2526

2627
Assistant assistant = assistantClient.CreateAssistant(
2728
"gpt-4o",

examples/Assistants/Example05_AssistantsWithVisionAsync.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ public async Task Example05_AssistantsWithVisionAsync()
2020
AssistantClient assistantClient = openAIClient.GetAssistantClient();
2121

2222
OpenAIFile pictureOfAppleFile = await fileClient.UploadFileAsync(
23-
Path.Combine("Assets", "picture-of-apple.png"),
23+
Path.Combine("Assets", "images_apple.png"),
2424
FileUploadPurpose.Vision);
25-
Uri linkToPictureOfOrange = new("https://raw.githubusercontent.com/openai/openai-dotnet/refs/heads/main/examples/Assets/picture-of-orange.png");
25+
26+
Uri linkToPictureOfOrange = new("https://raw.githubusercontent.com/openai/openai-dotnet/refs/heads/main/examples/Assets/images_orange.png");
2627

2728
Assistant assistant = await assistantClient.CreateAssistantAsync(
2829
"gpt-4o",

examples/Chat/Example02_SimpleChatStreaming.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public void Example02_SimpleChatStreaming()
1212
{
1313
ChatClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
1414

15-
CollectionResult<StreamingChatCompletionUpdate> completionUpdates
16-
= client.CompleteChatStreaming("Say 'this is a test.'");
15+
CollectionResult<StreamingChatCompletionUpdate> completionUpdates = client.CompleteChatStreaming("Say 'this is a test.'");
1716

1817
Console.Write($"[ASSISTANT]: ");
1918
foreach (StreamingChatCompletionUpdate completionUpdate in completionUpdates)

examples/Chat/Example02_SimpleChatStreamingAsync.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ public async Task Example02_SimpleChatStreamingAsync()
1313
{
1414
ChatClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
1515

16-
AsyncCollectionResult<StreamingChatCompletionUpdate> completionUpdates
17-
= client.CompleteChatStreamingAsync("Say 'this is a test.'");
16+
AsyncCollectionResult<StreamingChatCompletionUpdate> completionUpdates = client.CompleteChatStreamingAsync("Say 'this is a test.'");
1817

1918
Console.Write($"[ASSISTANT]: ");
2019
await foreach (StreamingChatCompletionUpdate completionUpdate in completionUpdates)

examples/Chat/Example03_FunctionCalling.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private static string GetCurrentWeather(string location, string unit = "celsius"
3131
private static readonly ChatTool getCurrentWeatherTool = ChatTool.CreateFunctionTool(
3232
functionName: nameof(GetCurrentWeather),
3333
functionDescription: "Get the current weather in a given location",
34-
functionParameters: BinaryData.FromString("""
34+
functionParameters: BinaryData.FromBytes("""
3535
{
3636
"type": "object",
3737
"properties": {
@@ -47,7 +47,7 @@ private static string GetCurrentWeather(string location, string unit = "celsius"
4747
},
4848
"required": [ "location" ]
4949
}
50-
""")
50+
"""u8.ToArray())
5151
);
5252
#endregion
5353

examples/Chat/Example06_StructuredOutputs.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void Example06_StructuredOutputs()
2222
{
2323
ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(
2424
jsonSchemaFormatName: "math_reasoning",
25-
jsonSchema: BinaryData.FromString("""
25+
jsonSchema: BinaryData.FromBytes("""
2626
{
2727
"type": "object",
2828
"properties": {
@@ -43,7 +43,7 @@ public void Example06_StructuredOutputs()
4343
"required": ["steps", "final_answer"],
4444
"additionalProperties": false
4545
}
46-
"""),
46+
"""u8.ToArray()),
4747
jsonSchemaIsStrict: true)
4848
};
4949

examples/Chat/Example06_StructuredOutputsAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task Example06_StructuredOutputsAsync()
2323
{
2424
ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(
2525
jsonSchemaFormatName: "math_reasoning",
26-
jsonSchema: BinaryData.FromString("""
26+
jsonSchema: BinaryData.FromBytes("""
2727
{
2828
"type": "object",
2929
"properties": {
@@ -44,7 +44,7 @@ public async Task Example06_StructuredOutputsAsync()
4444
"required": ["steps", "final_answer"],
4545
"additionalProperties": false
4646
}
47-
"""),
47+
"""u8.ToArray()),
4848
jsonSchemaIsStrict: true)
4949
};
5050

src/OpenAI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageTags>OpenAI;openai-dotnet;ChatGPT;Dall-E</PackageTags>
88

99
<VersionPrefix>2.0.0</VersionPrefix>
10-
<VersionSuffix>beta.13</VersionSuffix>
10+
<VersionSuffix></VersionSuffix>
1111

1212
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
1313
<LangVersion>latest</LangVersion>

0 commit comments

Comments
 (0)