Skip to content

Commit

Permalink
feat: Added ById methods for Constant classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jan 27, 2024
1 parent f1aa113 commit 991119f
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<PropertyGroup Label="Nuget">
<Version>2.0.0-alpha.8</Version>
<Version>2.0.0-alpha.9</Version>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>tryAGI and contributors</Authors>
Expand Down
37 changes: 37 additions & 0 deletions src/libs/OpenAI.Constants/Chat/ChatModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,41 @@ public override string ToString()
inputTokens * FineTuningPricePerInputTokenInUsd.Value +
outputTokens * FineTuningPricePerOutputTokenInUsd.Value;
}

/// <summary>
/// Returns <see cref="ChatModels"/> by <paramref name="id"/>. <br/>
/// Returns <see langword="null"/> if <paramref name="id"/> is not found.
/// </summary>
/// <param name="id">Id of the model.</param>
/// <returns></returns>
public static ChatModels? ById(string id)
{
return id switch
{
Gpt35Turbo_1106Id => Gpt35Turbo_1106,
Gpt35Turbo_0125Id => Gpt35Turbo_0125,
Gpt35TurboInstructId => Gpt35TurboInstruct,
Gpt35TurboId => Gpt35Turbo,

Gpt35Turbo_16kId => Gpt35Turbo_16k,
Gpt35Turbo_0613Id => Gpt35Turbo_0613,
Gpt35Turbo_16k_0613Id => Gpt35Turbo_16k_0613,
Gpt35Turbo_0301Id => Gpt35Turbo_0301,

Gpt4Id => Gpt4,
Gpt4_0613Id => Gpt4_0613,

Gpt4_32kId => Gpt4_32k,
Gpt4_32k_0613Id => Gpt4_32k_0613,

Gpt4_1106_PreviewId => Gpt4_1106_Preview,
Gpt4_0125_PreviewId => Gpt4_0125_Preview,
Gpt4TurboPreviewId => Gpt4TurboPreview,

Gpt4_1106_VisionPreviewId => Gpt4_1106_VisionPreview,
Gpt4VisionPreviewId => Gpt4VisionPreview,

_ => null,
};
}
}
19 changes: 19 additions & 0 deletions src/libs/OpenAI.Constants/Embedding/EmbeddingModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,23 @@ public override string ToString()
{
return tokens * PricePerTokenInUsd;
}

/// <summary>
/// Returns <see cref="EmbeddingModels"/> by <paramref name="id"/>. <br/>
/// Returns <see langword="null"/> if <paramref name="id"/> is not found.
/// </summary>
/// <param name="id">Id of the model.</param>
/// <returns></returns>
public static EmbeddingModels? ById(string id)
{
return id switch
{
Ada002Id => Ada002,

Version3SmallId => Version3Small,
Version3LargeId => Version3Large,

_ => null,
};
}
}
17 changes: 17 additions & 0 deletions src/libs/OpenAI.Constants/Image/ImageModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,21 @@ public override string ToString()
_ => throw new NotImplementedException(),
};
}

/// <summary>
/// Returns <see cref="ImageModels"/> by <paramref name="id"/>. <br/>
/// Returns <see langword="null"/> if <paramref name="id"/> is not found.
/// </summary>
/// <param name="id">Id of the model.</param>
/// <returns></returns>
public static ImageModels? ById(string id)
{
return id switch
{
DallE2Id => DallE2,
DallE3Id => DallE3,

_ => null,
};
}
}
17 changes: 17 additions & 0 deletions src/libs/OpenAI.Constants/Moderation/ModerationModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,21 @@ public override string ToString()
{
return model.Id;
}

/// <summary>
/// Returns <see cref="ModerationModels"/> by <paramref name="id"/>. <br/>
/// Returns <see langword="null"/> if <paramref name="id"/> is not found.
/// </summary>
/// <param name="id">Id of the model.</param>
/// <returns></returns>
public static ModerationModels? ById(string id)
{
return id switch
{
StableId => Stable,
LatestId => Latest,

_ => null,
};
}
}
16 changes: 16 additions & 0 deletions src/libs/OpenAI.Constants/SpeechToText/SpeechToTextModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,20 @@ public override string ToString()
{
return seconds * PricePerMinuteInUsd / 60.0;
}

/// <summary>
/// Returns <see cref="SpeechToTextModels"/> by <paramref name="id"/>. <br/>
/// Returns <see langword="null"/> if <paramref name="id"/> is not found.
/// </summary>
/// <param name="id">Id of the model.</param>
/// <returns></returns>
public static SpeechToTextModels? ById(string id)
{
return id switch
{
Whisper1Id => Whisper1,

_ => null,
};
}
}
17 changes: 17 additions & 0 deletions src/libs/OpenAI.Constants/TextToSpeech/TextToSpeechModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,21 @@ public override string ToString()
{
return characters * PricePerCharacterInUsd;
}

/// <summary>
/// Returns <see cref="TextToSpeechModels"/> by <paramref name="id"/>. <br/>
/// Returns <see langword="null"/> if <paramref name="id"/> is not found.
/// </summary>
/// <param name="id">Id of the model.</param>
/// <returns></returns>
public static TextToSpeechModels? ById(string id)
{
return id switch
{
Tts1Id => Tts1,
Tts1HdId => Tts1Hd,

_ => null,
};
}
}

0 comments on commit 991119f

Please sign in to comment.