From 23b2dcf4f592ee80a80a702b63b0b7521a30f0cc Mon Sep 17 00:00:00 2001 From: Tolga Kayhan Date: Tue, 24 Sep 2024 16:26:29 +0100 Subject: [PATCH 1/5] Azure DataPlane Endpoints are updated --- .../AzureOpenAiEndpointProvider.cs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/OpenAI.SDK/EndpointProviders/AzureOpenAiEndpointProvider.cs b/OpenAI.SDK/EndpointProviders/AzureOpenAiEndpointProvider.cs index c7bbaccd..ef3b0100 100644 --- a/OpenAI.SDK/EndpointProviders/AzureOpenAiEndpointProvider.cs +++ b/OpenAI.SDK/EndpointProviders/AzureOpenAiEndpointProvider.cs @@ -20,15 +20,16 @@ public AzureOpenAiEndpointProvider(string apiVersion, string deploymentId) private string Prefix => $"{ApiPrefix}/{DeploymentsPrefix}/{WebUtility.UrlEncode(_deploymentId)}"; private string AzureVersionQueryString => $"?api-version={_apiVersion}"; private string AssistantPrefix => $"{ApiPrefix}/"; + private string DataPlanePrefix => $"{ApiPrefix}/"; public string ModelRetrieve(string model) { - return $"{Prefix}/models/{model}{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/models/{model}{AzureVersionQueryString}"; } public string FileDelete(string fileId) { - return $"{Prefix}/files/{fileId}{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/files/{fileId}{AzureVersionQueryString}"; } public string CompletionCreate() @@ -43,7 +44,7 @@ public string EditCreate() public string ModelsList() { - return $"{Prefix}/models{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/models{AzureVersionQueryString}"; } public string FilesList() @@ -58,12 +59,12 @@ public string FilesUpload() public string FileRetrieve(string fileId) { - return $"{Prefix}/files/{fileId}{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/files/{fileId}{AzureVersionQueryString}"; } public string FileRetrieveContent(string fileId) { - return $"{Prefix}/files/{fileId}/content{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/files/{fileId}/content{AzureVersionQueryString}"; } public string FineTuneCreate() @@ -93,17 +94,17 @@ public string FineTuneListEvents(string fineTuneId) public string FineTuneDelete(string fineTuneId) { - return $"{Prefix}/models/{fineTuneId}{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/fine_tuning/jobs/{fineTuneId}{AzureVersionQueryString}"; } public string FineTuningJobCreate() { - return $"{Prefix}/fine_tuning/jobs{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/fine_tuning/jobs{AzureVersionQueryString}"; } public string FineTuningJobList(FineTuningJobListRequest? fineTuningJobListRequest) { - var url = $"{Prefix}/fine_tuning/jobs"; + var url = $"{DataPlanePrefix}/fine_tuning/jobs"; if (fineTuningJobListRequest != null) { var queryParams = new List(); @@ -121,22 +122,22 @@ public string FineTuningJobList(FineTuningJobListRequest? fineTuningJobListReque public string FineTuningJobRetrieve(string fineTuningJobId) { - return $"{Prefix}/fine_tuning/jobs/{fineTuningJobId}{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/fine_tuning/jobs/{fineTuningJobId}{AzureVersionQueryString}"; } public string FineTuningJobCancel(string fineTuningJobId) { - return $"{Prefix}/fine_tuning/jobs/{fineTuningJobId}/cancel{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/fine_tuning/jobs/{fineTuningJobId}/cancel{AzureVersionQueryString}"; } public string FineTuningJobListEvents(string fineTuningJobId) { - return $"{Prefix}/fine_tuning/jobs/{fineTuningJobId}/events{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/fine_tuning/jobs/{fineTuningJobId}/events{AzureVersionQueryString}"; } public string ModelsDelete(string modelId) { - return $"{Prefix}/models/{modelId}{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/models/{modelId}{AzureVersionQueryString}"; } public string EmbeddingCreate() @@ -451,26 +452,26 @@ public string VectorStoreFileBatchList(string vectorStoreId, string batchId, Pag public string BatchCreate() { - return $"{Prefix}/batches{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/batches{AzureVersionQueryString}"; } public string BatchRetrieve(string batchId) { - return $"{Prefix}/batches/{batchId}{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/batches/{batchId}{AzureVersionQueryString}"; } public string BatchCancel(string batchId) { - return $"{Prefix}/batches/{batchId}/cancel{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/batches/{batchId}/cancel{AzureVersionQueryString}"; } public string FineTuningJobList() { - return $"{Prefix}/fine_tuning/jobs{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/fine_tuning/jobs{AzureVersionQueryString}"; } private string Files() { - return $"{Prefix}/files{AzureVersionQueryString}"; + return $"{DataPlanePrefix}/files{AzureVersionQueryString}"; } } \ No newline at end of file From aaa7d8936a6bf32fe427d468ce0fec80fbb66023 Mon Sep 17 00:00:00 2001 From: Mungert69 Date: Wed, 2 Oct 2024 23:18:07 +0100 Subject: [PATCH 2/5] Added new PromptTokensDetails class. Added new PromptTokensDetails property to UsageResponse --- .../ResponseModels/PromptTokensDetails.cs | 11 +++++++++++ .../ObjectModels/ResponseModels/UsageResponse.cs | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs diff --git a/OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs b/OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs new file mode 100644 index 00000000..7abdb582 --- /dev/null +++ b/OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace OpenAI.ObjectModels.ResponseModels +{ + public class PromptTokensDetails + { + [JsonPropertyName("cached_tokens")] + public int? CachedTokens { get; set; } + } +} + diff --git a/OpenAI.SDK/ObjectModels/ResponseModels/UsageResponse.cs b/OpenAI.SDK/ObjectModels/ResponseModels/UsageResponse.cs index 4cd5f493..09ee57e1 100644 --- a/OpenAI.SDK/ObjectModels/ResponseModels/UsageResponse.cs +++ b/OpenAI.SDK/ObjectModels/ResponseModels/UsageResponse.cs @@ -15,4 +15,8 @@ public record UsageResponse [JsonPropertyName("completion_tokens_details")] public CompletionTokensDetails? CompletionTokensDetails { get; set; } -} \ No newline at end of file + + [JsonPropertyName("prompt_tokens_details")] + public PromptTokensDetails? PromptTokensDetails { get; set; } + +} From da0498590593d6db0974bb51fea130f1af53ddc4 Mon Sep 17 00:00:00 2001 From: Tolga Kayhan Date: Tue, 8 Oct 2024 19:18:09 +0100 Subject: [PATCH 3/5] added support for usage.audio_tokens --- .../ObjectModels/ResponseModels/CompletionTokensDetails.cs | 2 ++ OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenAI.SDK/ObjectModels/ResponseModels/CompletionTokensDetails.cs b/OpenAI.SDK/ObjectModels/ResponseModels/CompletionTokensDetails.cs index fecec639..115d5f41 100644 --- a/OpenAI.SDK/ObjectModels/ResponseModels/CompletionTokensDetails.cs +++ b/OpenAI.SDK/ObjectModels/ResponseModels/CompletionTokensDetails.cs @@ -6,4 +6,6 @@ public record CompletionTokensDetails { [JsonPropertyName("reasoning_tokens")] public int ReasoningTokens { get; set; } + [JsonPropertyName("audio_tokens")] + public int AudioTokens { get; set; } } \ No newline at end of file diff --git a/OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs b/OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs index 7abdb582..f368beb2 100644 --- a/OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs +++ b/OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs @@ -5,7 +5,9 @@ namespace OpenAI.ObjectModels.ResponseModels public class PromptTokensDetails { [JsonPropertyName("cached_tokens")] - public int? CachedTokens { get; set; } + public int? CachedTokens { get; set; } + [JsonPropertyName("audio_tokens")] + public int? AudioTokens { get; set; } } } From 59ec6e30a763978e61dc5fa2c2924d5ccd0a7ff4 Mon Sep 17 00:00:00 2001 From: Tolga Kayhan Date: Thu, 10 Oct 2024 12:41:19 +0100 Subject: [PATCH 4/5] Updated the model list to include support for new models. --- OpenAI.SDK/ObjectModels/Models.cs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/OpenAI.SDK/ObjectModels/Models.cs b/OpenAI.SDK/ObjectModels/Models.cs index c2d1a9b6..6e9f0e0e 100644 --- a/OpenAI.SDK/ObjectModels/Models.cs +++ b/OpenAI.SDK/ObjectModels/Models.cs @@ -98,8 +98,10 @@ public enum Model Gpt_4_turbo_2024_04_09, Gpt_4o, Gpt_4o_2024_05_13, + Gpt_4o_2024_08_06, Gpt_4o_mini, Gpt_4o_mini_2024_07_18, + Chatgpt_4o_latest, WhisperV1, @@ -213,18 +215,27 @@ public enum Subject public static string Gpt_4_turbo_2024_04_09 => "gpt-4-turbo-2024-04-09"; /// - /// Our most advanced, multimodal flagship model that’s cheaper and faster than GPT-4 Turbo. - /// Currently points to gpt-4o-2024-05-13. - /// 128,000 tokens Up to Oct 2023 + /// GPT-4o: Our high-intelligence flagship model for complex, multi-step tasks. GPT-4o is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-08-06. + /// Context Window: 128,000 tokens + /// Max output tokens: 16,384 tokens + /// Training data: Up to Oct 2023 /// public static string Gpt_4o => "gpt-4o"; /// - /// Our most advanced, multimodal flagship model that’s cheaper and faster than GPT-4 Turbo. - /// Currently points to gpt-4o-2024-05-13. - /// 128,000 tokens Up to Oct 2023 + /// Original gpt-4o snapshot from May 13, 2024. + /// Context Window: 128,000 tokens + /// Max output tokens: 4,096 tokens + /// Training data: Up to Oct 2023 /// public static string Gpt_4o_2024_05_13 => "gpt-4o-2024-05-13"; + /// + /// Latest snapshot that supports Structured Outputs. gpt-4o currently points to this version. + /// Context Window: 128,000 tokens + /// Max output tokens: 16,384 tokens + /// Training data: Up to Oct 2023 + /// + public static string Gpt_4o_2024_08_06 => "gpt-4o-2024-08-06"; /// /// Our affordable and intelligent small model for fast, lightweight tasks. @@ -242,6 +253,11 @@ public enum Subject /// public static string Gpt_4o_mini_2024_07_18 => "gpt-4o-mini-2024-07-18"; + /// + /// Dynamic model continuously updated to the current version of GPT-4o in ChatGPT. Intended for research and evaluation [1]. + /// + public static string Chatgpt_4o_latest => "chatgpt-4o-latest"; + public static string Ada => "ada"; public static string Babbage => "babbage"; @@ -495,8 +511,10 @@ public static string EnumToString(this Model model) Model.Gpt_4_turbo_2024_04_09 => Gpt_4_turbo_2024_04_09, Model.Gpt_4o => Gpt_4o, Model.Gpt_4o_2024_05_13 => Gpt_4o_2024_05_13, + Model.Gpt_4o_2024_08_06 => Gpt_4o_2024_08_06, Model.Gpt_4o_mini => Gpt_4o_mini, Model.Gpt_4o_mini_2024_07_18 => Gpt_4o_mini_2024_07_18, + Model.Chatgpt_4o_latest => Chatgpt_4o_latest, Model.Tts_1 => Tts_1, Model.Tts_1_hd => Tts_1_hd, Model.Text_moderation_007 => TextModeration007, From 921ba2c2fb278bd47c94ec140ef621ac168b4aa0 Mon Sep 17 00:00:00 2001 From: Tolga Kayhan Date: Thu, 10 Oct 2024 12:59:16 +0100 Subject: [PATCH 5/5] version bump --- OpenAI.SDK/OpenAI.csproj | 2 +- Readme.md | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenAI.SDK/OpenAI.csproj b/OpenAI.SDK/OpenAI.csproj index 81487c0c..0dfaaf6e 100644 --- a/OpenAI.SDK/OpenAI.csproj +++ b/OpenAI.SDK/OpenAI.csproj @@ -10,7 +10,7 @@ Betalgo-Ranul-OpenAI-icon.png true OpenAI SDK by Betalgo - 8.7.1 + 8.7.2 Tolga Kayhan, Betalgo Betalgo Up Ltd. OpenAI ChatGPT, Whisper, GPT-4 and DALL·E dotnet SDK diff --git a/Readme.md b/Readme.md index 9f7aa5d4..730e99df 100644 --- a/Readme.md +++ b/Readme.md @@ -115,8 +115,14 @@ Due to time constraints, not all methods have been thoroughly tested or fully do Needless to say, I cannot accept responsibility for any damage caused by using the library. ## Changelog +### 8.7.2 +- Fixed incorrect Azure Urls. +- Token usage response extended with `PromptTokensDetails`, `audio_tokens` and `cached_tokens`. +- Model list extended with `Gpt_4o_2024_08_06` and `Chatgpt_4o_latest`. + ### 8.7.1 -- moved `strict ` paremeter from `ToolDefinition` to `FunctionDefinition` +- moved `strict` paremeter from `ToolDefinition` to `FunctionDefinition` + ### 8.7.0 - Added Support for o1 reasing models (`o1-mini` and `o1-preview`). - Added `MaxCompletionTokens` for `chat completions`.