-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
209 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace OpenAI.Constants; | ||
|
||
/// <summary> | ||
/// All prices in USD. <br/> | ||
/// According https://openai.com/pricing/ <br/> | ||
/// </summary> | ||
public static class FineTuningPrices | ||
{ | ||
/// <inheritdoc cref="FineTuningPrices"/> | ||
/// <param name="model"></param> | ||
/// <param name="trainingTokens"></param> | ||
/// <param name="inputTokens"></param> | ||
/// <param name="outputTokens"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public static double? TryGet( | ||
ChatModel model, | ||
int trainingTokens, | ||
int inputTokens, | ||
int outputTokens) | ||
{ | ||
var (trainingPricePerToken, inputPricePerToken, outputPricePerToken) = model.Value switch | ||
{ | ||
ChatModel.Gpt35TurboValue => (0.0080 * 0.001, 0.0030 * 0.001, 0.0060 * 0.001), | ||
|
||
_ => (-1.0, -1.0, -1.0), | ||
}; | ||
if (trainingPricePerToken < 0.0) | ||
{ | ||
return null; | ||
} | ||
|
||
return trainingTokens * trainingPricePerToken + | ||
inputTokens * inputPricePerToken + | ||
outputTokens * outputPricePerToken; | ||
} | ||
|
||
/// <inheritdoc cref="TryGet(ChatModel, int, int, int)"/> | ||
public static double Get( | ||
ChatModel model, | ||
int trainingTokens, | ||
int inputTokens, | ||
int outputTokens) | ||
{ | ||
return TryGet( | ||
model: model, | ||
trainingTokens: trainingTokens, | ||
inputTokens: inputTokens, | ||
outputTokens: outputTokens) ?? | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/libs/OpenAI.Constants/TextToSpeech/TextToSpeechModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace OpenAI.Constants; | ||
|
||
/// <summary> | ||
/// According https://platform.openai.com/docs/guides/text-to-speech | ||
/// </summary> | ||
public readonly record struct TextToSpeechModel(string Value) | ||
{ | ||
/// <summary> | ||
/// Transcribe audio into whatever language the audio is in. <br/> | ||
/// File uploads are currently limited to 25 MB and the following input file types are supported: mp3, mp4, mpeg, mpga, m4a, wav, and webm. <br/> | ||
/// </summary> | ||
internal const string Tts1Value = "tts-1"; | ||
|
||
/// <summary> | ||
/// Transcribe audio into whatever language the audio is in. <br/> | ||
/// File uploads are currently limited to 25 MB and the following input file types are supported: mp3, mp4, mpeg, mpga, m4a, wav, and webm. <br/> | ||
/// </summary> | ||
internal const string Tts1HdValue = "tts-1-hd"; | ||
|
||
/// <inheritdoc cref="Tts1Value"/> | ||
public static TextToSpeechModel Tts1 { get; } = new(Tts1Value); | ||
|
||
/// <inheritdoc cref="Tts1HdValue"/> | ||
public static TextToSpeechModel Tts1Hd { get; } = new(Tts1HdValue); | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() | ||
{ | ||
return Value; | ||
} | ||
|
||
/// <summary> | ||
/// Implicitly converts <see cref="TextToSpeechModel"/> to <see cref="string"/>. | ||
/// </summary> | ||
/// <param name="model"></param> | ||
/// <returns></returns> | ||
public static implicit operator string(TextToSpeechModel model) | ||
{ | ||
return model.Value; | ||
} | ||
} |
Oops, something went wrong.