Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.7.2 #651

Merged
merged 8 commits into from
Oct 10, 2024
Merged

8.7.2 #651

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
35 changes: 18 additions & 17 deletions OpenAI.SDK/EndpointProviders/AzureOpenAiEndpointProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -43,7 +44,7 @@ public string EditCreate()

public string ModelsList()
{
return $"{Prefix}/models{AzureVersionQueryString}";
return $"{DataPlanePrefix}/models{AzureVersionQueryString}";
}

public string FilesList()
Expand All @@ -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()
Expand Down Expand Up @@ -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<string>();
Expand All @@ -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()
Expand Down Expand Up @@ -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}";
}
}
30 changes: 24 additions & 6 deletions OpenAI.SDK/ObjectModels/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -213,18 +215,27 @@ public enum Subject
public static string Gpt_4_turbo_2024_04_09 => "gpt-4-turbo-2024-04-09";

/// <summary>
/// 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
/// </summary>
public static string Gpt_4o => "gpt-4o";

/// <summary>
/// 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
/// </summary>
public static string Gpt_4o_2024_05_13 => "gpt-4o-2024-05-13";
/// <summary>
/// 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
/// </summary>
public static string Gpt_4o_2024_08_06 => "gpt-4o-2024-08-06";

/// <summary>
/// Our affordable and intelligent small model for fast, lightweight tasks.
Expand All @@ -242,6 +253,11 @@ public enum Subject
/// </summary>
public static string Gpt_4o_mini_2024_07_18 => "gpt-4o-mini-2024-07-18";

/// <summary>
/// Dynamic model continuously updated to the current version of GPT-4o in ChatGPT. <a href="https://platform.openai.com/docs/models#4ofootnote">Intended for research and evaluation [1]</a>.
/// </summary>
public static string Chatgpt_4o_latest => "chatgpt-4o-latest";


public static string Ada => "ada";
public static string Babbage => "babbage";
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ public record CompletionTokensDetails
{
[JsonPropertyName("reasoning_tokens")]
public int ReasoningTokens { get; set; }
[JsonPropertyName("audio_tokens")]
public int AudioTokens { get; set; }
}
13 changes: 13 additions & 0 deletions OpenAI.SDK/ObjectModels/ResponseModels/PromptTokensDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Text.Json.Serialization;

namespace OpenAI.ObjectModels.ResponseModels
{
public class PromptTokensDetails
{
[JsonPropertyName("cached_tokens")]
public int? CachedTokens { get; set; }
[JsonPropertyName("audio_tokens")]
public int? AudioTokens { get; set; }
}
}

6 changes: 5 additions & 1 deletion OpenAI.SDK/ObjectModels/ResponseModels/UsageResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ public record UsageResponse

[JsonPropertyName("completion_tokens_details")]
public CompletionTokensDetails? CompletionTokensDetails { get; set; }
}

[JsonPropertyName("prompt_tokens_details")]
public PromptTokensDetails? PromptTokensDetails { get; set; }

}
2 changes: 1 addition & 1 deletion OpenAI.SDK/OpenAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageIcon>Betalgo-Ranul-OpenAI-icon.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>OpenAI SDK by Betalgo</Title>
<Version>8.7.1</Version>
<Version>8.7.2</Version>
<Authors>Tolga Kayhan, Betalgo</Authors>
<Company>Betalgo Up Ltd.</Company>
<Product>OpenAI ChatGPT, Whisper, GPT-4 and DALL·E dotnet SDK</Product>
Expand Down
8 changes: 7 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
Loading