AI-Studio/app/MindWork AI Studio/Provider/Providers.cs

44 lines
1.2 KiB
C#
Raw Normal View History

2024-04-20 15:06:50 +00:00
using AIStudio.Provider.OpenAI;
namespace AIStudio.Provider;
2024-05-04 08:55:00 +00:00
/// <summary>
/// Enum for all available providers.
/// </summary>
2024-04-20 15:06:50 +00:00
public enum Providers
{
NONE,
OPEN_AI,
}
2024-05-04 08:55:00 +00:00
/// <summary>
/// Extension methods for the provider enum.
/// </summary>
2024-04-20 15:06:50 +00:00
public static class ExtensionsProvider
{
2024-05-04 08:55:00 +00:00
/// <summary>
/// Returns the human-readable name of the provider.
/// </summary>
/// <param name="provider">The provider.</param>
/// <returns>The human-readable name of the provider.</returns>
2024-04-20 15:06:50 +00:00
public static string ToName(this Providers provider) => provider switch
{
Providers.OPEN_AI => "OpenAI",
2024-05-19 14:07:43 +00:00
Providers.NONE => "No provider selected",
2024-04-20 15:06:50 +00:00
_ => "Unknown",
};
2024-05-04 08:55:00 +00:00
/// <summary>
/// Creates a new provider instance based on the provider value.
/// </summary>
/// <param name="provider">The provider value.</param>
/// <param name="instanceName">The used instance name.</param>
2024-05-04 08:55:00 +00:00
/// <returns>The provider instance.</returns>
public static IProvider CreateProvider(this Providers provider, string instanceName) => provider switch
2024-04-20 15:06:50 +00:00
{
Providers.OPEN_AI => new ProviderOpenAI { InstanceName = instanceName },
2024-04-20 15:06:50 +00:00
_ => new NoProvider(),
};
}