Skip to content

Commit

Permalink
Prepare 2.0.0 release (Part 2) (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
joseharriaga authored Sep 30, 2024
1 parent 31c2ba6 commit e4af169
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 89 deletions.
37 changes: 27 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
# Release History

## 2.0.0-beta.14 (Unreleased)
## 2.0.0 (2024-09-30)

> [!NOTE]
> First stable version of the official OpenAI library for .NET.
### Features Added

- Support for OpenAI's latest flagship models, including GPT-4o, GPT-4o mini, o1-preview, and o1-mini
- Support for the entire OpenAI REST API, including:
- Structured outputs
- Reasoning tokens
- Experimental support for Assistants beta v2
- Support for sync and async APIs
- Convenient APIs to facilitate working with streaming chat completions and assistants
- Tons of other quality-of-life features for ease of use and productivity

### Breaking Changes

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

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

Expand Down
120 changes: 60 additions & 60 deletions README.md

Large diffs are not rendered by default.

File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions examples/Assistants/Example01_RetrievalAugmentedGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void Example01_RetrievalAugmentedGeneration()
AssistantClient assistantClient = openAIClient.GetAssistantClient();

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

OpenAIFile salesFile = fileClient.UploadFile(
document,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task Example01_RetrievalAugmentedGenerationAsync()
AssistantClient assistantClient = openAIClient.GetAssistantClient();

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

OpenAIFile salesFile = await fileClient.UploadFileAsync(
document,
Expand Down
5 changes: 3 additions & 2 deletions examples/Assistants/Example05_AssistantsWithVision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ public void Example05_AssistantsWithVision()
AssistantClient assistantClient = openAIClient.GetAssistantClient();

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

Uri linkToPictureOfOrange = new("https://raw.githubusercontent.com/openai/openai-dotnet/refs/heads/main/examples/Assets/images_orange.png");

Assistant assistant = assistantClient.CreateAssistant(
"gpt-4o",
Expand Down
5 changes: 3 additions & 2 deletions examples/Assistants/Example05_AssistantsWithVisionAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public async Task Example05_AssistantsWithVisionAsync()
AssistantClient assistantClient = openAIClient.GetAssistantClient();

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

Uri linkToPictureOfOrange = new("https://raw.githubusercontent.com/openai/openai-dotnet/refs/heads/main/examples/Assets/images_orange.png");

Assistant assistant = await assistantClient.CreateAssistantAsync(
"gpt-4o",
Expand Down
3 changes: 1 addition & 2 deletions examples/Chat/Example02_SimpleChatStreaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public void Example02_SimpleChatStreaming()
{
ChatClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));

CollectionResult<StreamingChatCompletionUpdate> completionUpdates
= client.CompleteChatStreaming("Say 'this is a test.'");
CollectionResult<StreamingChatCompletionUpdate> completionUpdates = client.CompleteChatStreaming("Say 'this is a test.'");

Console.Write($"[ASSISTANT]: ");
foreach (StreamingChatCompletionUpdate completionUpdate in completionUpdates)
Expand Down
3 changes: 1 addition & 2 deletions examples/Chat/Example02_SimpleChatStreamingAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public async Task Example02_SimpleChatStreamingAsync()
{
ChatClient client = new(model: "gpt-4o", apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY"));

AsyncCollectionResult<StreamingChatCompletionUpdate> completionUpdates
= client.CompleteChatStreamingAsync("Say 'this is a test.'");
AsyncCollectionResult<StreamingChatCompletionUpdate> completionUpdates = client.CompleteChatStreamingAsync("Say 'this is a test.'");

Console.Write($"[ASSISTANT]: ");
await foreach (StreamingChatCompletionUpdate completionUpdate in completionUpdates)
Expand Down
4 changes: 2 additions & 2 deletions examples/Chat/Example03_FunctionCalling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static string GetCurrentWeather(string location, string unit = "celsius"
private static readonly ChatTool getCurrentWeatherTool = ChatTool.CreateFunctionTool(
functionName: nameof(GetCurrentWeather),
functionDescription: "Get the current weather in a given location",
functionParameters: BinaryData.FromString("""
functionParameters: BinaryData.FromBytes("""
{
"type": "object",
"properties": {
Expand All @@ -47,7 +47,7 @@ private static string GetCurrentWeather(string location, string unit = "celsius"
},
"required": [ "location" ]
}
""")
"""u8.ToArray())
);
#endregion

Expand Down
4 changes: 2 additions & 2 deletions examples/Chat/Example06_StructuredOutputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void Example06_StructuredOutputs()
{
ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(
jsonSchemaFormatName: "math_reasoning",
jsonSchema: BinaryData.FromString("""
jsonSchema: BinaryData.FromBytes("""
{
"type": "object",
"properties": {
Expand All @@ -43,7 +43,7 @@ public void Example06_StructuredOutputs()
"required": ["steps", "final_answer"],
"additionalProperties": false
}
"""),
"""u8.ToArray()),
jsonSchemaIsStrict: true)
};

Expand Down
4 changes: 2 additions & 2 deletions examples/Chat/Example06_StructuredOutputsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task Example06_StructuredOutputsAsync()
{
ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(
jsonSchemaFormatName: "math_reasoning",
jsonSchema: BinaryData.FromString("""
jsonSchema: BinaryData.FromBytes("""
{
"type": "object",
"properties": {
Expand All @@ -44,7 +44,7 @@ public async Task Example06_StructuredOutputsAsync()
"required": ["steps", "final_answer"],
"additionalProperties": false
}
"""),
"""u8.ToArray()),
jsonSchemaIsStrict: true)
};

Expand Down
2 changes: 1 addition & 1 deletion src/OpenAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageTags>OpenAI;openai-dotnet;ChatGPT;Dall-E</PackageTags>

<VersionPrefix>2.0.0</VersionPrefix>
<VersionSuffix>beta.13</VersionSuffix>
<VersionSuffix></VersionSuffix>

<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
Expand Down

0 comments on commit e4af169

Please sign in to comment.