Skip to content

Commit

Permalink
feat: Added ChatModelMetadata Id property.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 20, 2024
1 parent 58076f2 commit 093dc87
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/libs/OpenAI/Metadata/ChatModelMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ namespace OpenAI;
/// </summary>
public class ChatModelMetadata
{
/// <summary>
/// Price per training token in USD.
/// </summary>
public string? Id { get; init; }

/// <summary>
/// Price per training token in USD.
/// </summary>
Expand Down
15 changes: 14 additions & 1 deletion src/libs/OpenAI/Metadata/Metadata.Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static ChatModelMetadata GetChatModelMetadata(
CreateChatCompletionRequestModel.Gpt4o or
CreateChatCompletionRequestModel.Gpt4o20240513 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 5.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 15.0 * UsdPerMillionTokens,
ContextLength = 128_000,
Expand All @@ -24,6 +25,7 @@ CreateChatCompletionRequestModel.Gpt4o or
CreateChatCompletionRequestModel.Gpt4oMini or
CreateChatCompletionRequestModel.Gpt4oMini20240718 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 0.15 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 0.60 * UsdPerMillionTokens,
ContextLength = 128_000,
Expand All @@ -37,6 +39,7 @@ CreateChatCompletionRequestModel.Gpt4TurboPreview or
CreateChatCompletionRequestModel.Gpt41106Preview or
CreateChatCompletionRequestModel.Gpt4VisionPreview => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 10.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 30.0 * UsdPerMillionTokens,
ContextLength = 128_000,
Expand All @@ -47,6 +50,7 @@ CreateChatCompletionRequestModel.Gpt4 or
CreateChatCompletionRequestModel.Gpt40314 or
CreateChatCompletionRequestModel.Gpt40613 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 30.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 60.0 * UsdPerMillionTokens,
ContextLength = 8_192,
Expand All @@ -57,6 +61,7 @@ CreateChatCompletionRequestModel.Gpt432k or
CreateChatCompletionRequestModel.Gpt432k0314 or
CreateChatCompletionRequestModel.Gpt432k0613 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 60.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 120.0 * UsdPerMillionTokens,
ContextLength = 32_768,
Expand All @@ -66,6 +71,7 @@ CreateChatCompletionRequestModel.Gpt432k0314 or
CreateChatCompletionRequestModel.Gpt35Turbo or
CreateChatCompletionRequestModel.Gpt35Turbo0125 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 0.5 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 1.5 * UsdPerMillionTokens,
ContextLength = 16_385,
Expand All @@ -77,20 +83,23 @@ CreateChatCompletionRequestModel.Gpt35Turbo or
},
CreateChatCompletionRequestModel.Gpt35Turbo1106 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 1.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 2.0 * UsdPerMillionTokens,
ContextLength = 16_385,
OutputLength = 16_000,
},
CreateChatCompletionRequestModel.Gpt35Turbo0613 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 1.5 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 2.0 * UsdPerMillionTokens,
ContextLength = 4_096,
OutputLength = 16_000,
},
CreateChatCompletionRequestModel.Gpt35Turbo0301 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 2.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 2.0 * UsdPerMillionTokens,
ContextLength = 4_096,
Expand All @@ -99,13 +108,17 @@ CreateChatCompletionRequestModel.Gpt35Turbo or
CreateChatCompletionRequestModel.Gpt35Turbo16k or
CreateChatCompletionRequestModel.Gpt35Turbo16k0613 => new ChatModelMetadata
{
Id = model.ToValueString(),
PricePerInputTokenInUsd = 3.0 * UsdPerMillionTokens,
PricePerOutputTokenInUsd = 4.0 * UsdPerMillionTokens,
ContextLength = 16_385,
OutputLength = 16_000,
},

_ => new ChatModelMetadata(),
_ => new ChatModelMetadata
{
Id = model.ToValueString(),
},
};
}

Expand Down

0 comments on commit 093dc87

Please sign in to comment.