using AIStudio.Provider.Anthropic; using AIStudio.Provider.Mistral; using AIStudio.Provider.OpenAI; using AIStudio.Provider.SelfHosted; namespace AIStudio.Provider; /// /// Enum for all available providers. /// public enum Providers { NONE, OPEN_AI, ANTHROPIC, MISTRAL, SELF_HOSTED, } /// /// Extension methods for the provider enum. /// public static class ExtensionsProvider { /// /// Returns the human-readable name of the provider. /// /// The provider. /// The human-readable name of the provider. public static string ToName(this Providers provider) => provider switch { Providers.NONE => "No provider selected", Providers.OPEN_AI => "OpenAI", Providers.ANTHROPIC => "Anthropic", Providers.MISTRAL => "Mistral", Providers.SELF_HOSTED => "Self-hosted", _ => "Unknown", }; /// /// Creates a new provider instance based on the provider value. /// /// The provider value. /// The used instance name. /// The hostname of the provider. /// The provider instance. public static IProvider CreateProvider(this Providers provider, string instanceName, string hostname = "http://localhost:1234") => provider switch { Providers.OPEN_AI => new ProviderOpenAI { InstanceName = instanceName }, Providers.ANTHROPIC => new ProviderAnthropic { InstanceName = instanceName }, Providers.MISTRAL => new ProviderMistral { InstanceName = instanceName }, Providers.SELF_HOSTED => new ProviderSelfHosted(hostname) { InstanceName = instanceName }, _ => new NoProvider(), }; }