Skip to content

Commit 19ceae4

Browse files
authored
Refactor and rename types and properties for consistency and clarity (#225)
### Summary of Changes This PR renames the following types and properties for consistency and clarity: - **Types:** - `OpenAIFileInfo` → `OpenAIFile` - `OpenAIFileInfoCollection` → `OpenAIFileCollection` - `OpenAIModelInfo` → `OpenAIModel` - `OpenAIModelInfoCollection` → `OpenAIModelCollection` - `Embedding` → `OpenAIEmbedding` - `EmbeddingCollection` → `OpenAIEmbeddingCollection` - **Properties and Methods:** - `ImageUrl` → `ImageUri` and method `FromImageUrl` → `FromImageUri` in `MessageContent` - `ParallelToolCallsEnabled` → `AllowParallelToolCalls` in `RunCreationOptions`, `ThreadRun`, and `ChatCompletionOptions` - `PromptTokens` → `InputTokenCount`, `CompletionTokens` → `OutputTokenCount`, and `TotalTokens` → `TotalTokenCount` in `RunTokenUsage` - `InputTokens` → `InputTokenCount` and `TotalTokens` → `TotalTokenCount` in `EmbeddingTokenUsage` This PR also refactors the `ModerationResult` type to consolidate category-specific flags and scores into individual `ModerationCategory` properties, each containing `Flagged` and `Score` properties: ```csharp public class ModerationResult { public bool Flagged { get; } public ModerationCategory Harassment { get; } public ModerationCategory HarassmentThreatening { get; } public ModerationCategory Hate { get; } public ModerationCategory HateThreatening { get; } public ModerationCategory SelfHarm { get; } public ModerationCategory SelfHarmInstructions { get; } public ModerationCategory SelfHarmIntent { get; } public ModerationCategory Sexual { get; } public ModerationCategory SexualMinors { get; } public ModerationCategory Violence { get; } public ModerationCategory ViolenceGraphic { get; } } public class ModerationCategory { public bool Flagged { get; } public float Score { get; } } ``` Additionally, this PR includes smoke tests for the `ModerationResult` type.
1 parent 7a8bc8b commit 19ceae4

File tree

101 files changed

+1679
-1540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1679
-1540
lines changed

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Release History
22

3+
## 2.0.0-beta.13 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
- Refactored `ModerationResult` by merging `ModerationCategories` and `ModerationCategoryScores` into individual `ModerationCategory` properties, each with `Flagged` and `Score` properties. (commit_hash)
10+
- Renamed type `OpenAIFileInfo` to `OpenAIFile` and `OpenAIFileInfoCollection` to `OpenAIFileCollection`. (commit_id)
11+
- Renamed type `OpenAIModelInfo` to `OpenAIModel` and `OpenAIModelInfoCollection` to `OpenAIModelCollection`. (commit_id)
12+
- Renamed type `Embedding` to `OpenAIEmbedding` and `EmbeddingCollection` to `OpenAIEmbeddingCollection`. (commit_id)
13+
- Renamed property `ImageUrl` to `ImageUri` and method `FromImageUrl` to `FromImageUri` in `MessageContent`. (commit_id)
14+
- Renamed property `ParallelToolCallsEnabled` to `AllowParallelToolCalls` in `RunCreationOptions`, `ThreadRun`, and `ChatCompletionOptions` types. (commit_id)
15+
- Renamed property `PromptTokens` to `InputTokenCount`, `CompletionTokens` to `OutputTokenCount`, and `TotalTokens` to `TotalTokenCount` in `RunTokenUsage`. (commit_id)
16+
- Renamed property `InputTokens` to `InputTokenCount` and `TotalTokens` to `TotalTokenCount` in `EmbeddingTokenUsage`. (commit_id)
17+
18+
### Bugs Fixed
19+
20+
### Other Changes
21+
322
## 2.0.0-beta.12 (2024-09-20)
423

524
### Features Added

api/OpenAI.netstandard2.0.cs

Lines changed: 119 additions & 143 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
@@ -49,7 +49,7 @@ public void Example01_RetrievalAugmentedGeneration()
4949
}
5050
""").ToStream();
5151

52-
OpenAIFileInfo salesFile = fileClient.UploadFile(
52+
OpenAIFile salesFile = fileClient.UploadFile(
5353
document,
5454
"monthly_sales.json",
5555
FileUploadPurpose.Assistants);
@@ -129,7 +129,7 @@ CollectionResult<ThreadMessage> messages
129129
}
130130
if (!string.IsNullOrEmpty(contentItem.ImageFileId))
131131
{
132-
OpenAIFileInfo imageInfo = fileClient.GetFile(contentItem.ImageFileId);
132+
OpenAIFile imageInfo = fileClient.GetFile(contentItem.ImageFileId);
133133
BinaryData imageBytes = fileClient.DownloadFile(contentItem.ImageFileId);
134134
using FileStream stream = File.OpenWrite($"{imageInfo.Filename}.png");
135135
imageBytes.ToStream().CopyTo(stream);

examples/Assistants/Example01_RetrievalAugmentedGenerationAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public async Task Example01_RetrievalAugmentedGenerationAsync()
5050
}
5151
""").ToStream();
5252

53-
OpenAIFileInfo salesFile = await fileClient.UploadFileAsync(
53+
OpenAIFile salesFile = await fileClient.UploadFileAsync(
5454
document,
5555
"monthly_sales.json",
5656
FileUploadPurpose.Assistants);
@@ -130,7 +130,7 @@ AsyncCollectionResult<ThreadMessage> messages
130130
}
131131
if (!string.IsNullOrEmpty(contentItem.ImageFileId))
132132
{
133-
OpenAIFileInfo imageInfo = await fileClient.GetFileAsync(contentItem.ImageFileId);
133+
OpenAIFile imageInfo = await fileClient.GetFileAsync(contentItem.ImageFileId);
134134
BinaryData imageBytes = await fileClient.DownloadFileAsync(contentItem.ImageFileId);
135135
using FileStream stream = File.OpenWrite($"{imageInfo.Filename}.png");
136136
imageBytes.ToStream().CopyTo(stream);

examples/Assistants/Example04_AllTheTools.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static string GetNameOfFamilyMember(string relation)
4444

4545
#region Upload a mock file for use with file search
4646
FileClient fileClient = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY"));
47-
OpenAIFileInfo favoriteNumberFile = fileClient.UploadFile(
47+
OpenAIFile favoriteNumberFile = fileClient.UploadFile(
4848
BinaryData.FromString("""
4949
This file contains the favorite numbers for individuals.
5050

examples/Assistants/Example05_AssistantsWithVision.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void Example05_AssistantsWithVision()
1616
FileClient fileClient = openAIClient.GetFileClient();
1717
AssistantClient assistantClient = openAIClient.GetAssistantClient();
1818

19-
OpenAIFileInfo pictureOfAppleFile = fileClient.UploadFile(
19+
OpenAIFile pictureOfAppleFile = fileClient.UploadFile(
2020
"picture-of-apple.jpg",
2121
FileUploadPurpose.Vision);
2222
Uri linkToPictureOfOrange = new("https://platform.openai.com/fictitious-files/picture-of-orange.png");
@@ -38,7 +38,7 @@ public void Example05_AssistantsWithVision()
3838
[
3939
"Hello, assistant! Please compare these two images for me:",
4040
MessageContent.FromImageFileId(pictureOfAppleFile.Id),
41-
MessageContent.FromImageUrl(linkToPictureOfOrange),
41+
MessageContent.FromImageUri(linkToPictureOfOrange),
4242
]),
4343
}
4444
});

examples/Assistants/Example05_AssistantsWithVisionAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public async Task Example05_AssistantsWithVisionAsync()
1717
FileClient fileClient = openAIClient.GetFileClient();
1818
AssistantClient assistantClient = openAIClient.GetAssistantClient();
1919

20-
OpenAIFileInfo pictureOfAppleFile = await fileClient.UploadFileAsync(
20+
OpenAIFile pictureOfAppleFile = await fileClient.UploadFileAsync(
2121
"picture-of-apple.jpg",
2222
FileUploadPurpose.Vision);
2323
Uri linkToPictureOfOrange = new("https://platform.openai.com/fictitious-files/picture-of-orange.png");
@@ -39,7 +39,7 @@ public async Task Example05_AssistantsWithVisionAsync()
3939
[
4040
"Hello, assistant! Please compare these two images for me:",
4141
MessageContent.FromImageFileId(pictureOfAppleFile.Id),
42-
MessageContent.FromImageUrl(linkToPictureOfOrange),
42+
MessageContent.FromImageUri(linkToPictureOfOrange),
4343
]),
4444
}
4545
});

examples/Embeddings/Example01_SimpleEmbedding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void Example01_SimpleEmbedding()
1515
+ " and a really helpful concierge. The location is perfect -- right downtown, close to all the tourist"
1616
+ " attractions. We highly recommend this hotel.";
1717

18-
Embedding embedding = client.GenerateEmbedding(description);
18+
OpenAIEmbedding embedding = client.GenerateEmbedding(description);
1919
ReadOnlyMemory<float> vector = embedding.ToFloats();
2020

2121
Console.WriteLine($"Dimension: {vector.Length}");

examples/Embeddings/Example01_SimpleEmbeddingAsync.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public async Task Example01_SimpleEmbeddingAsync()
1616
+ " and a really helpful concierge. The location is perfect -- right downtown, close to all the tourist"
1717
+ " attractions. We highly recommend this hotel.";
1818

19-
Embedding embedding = await client.GenerateEmbeddingAsync(description);
19+
OpenAIEmbedding embedding = await client.GenerateEmbeddingAsync(description);
2020
ReadOnlyMemory<float> vector = embedding.ToFloats();
2121

2222
Console.WriteLine($"Dimension: {vector.Length}");

examples/Embeddings/Example02_EmbeddingWithOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void Example02_EmbeddingWithOptions()
1717

1818
EmbeddingGenerationOptions options = new() { Dimensions = 512 };
1919

20-
Embedding embedding = client.GenerateEmbedding(description, options);
20+
OpenAIEmbedding embedding = client.GenerateEmbedding(description, options);
2121
ReadOnlyMemory<float> vector = embedding.ToFloats();
2222

2323
Console.WriteLine($"Dimension: {vector.Length}");

0 commit comments

Comments
 (0)