using AIStudio.Provider;
namespace AIStudio.Settings;
public static partial class ProviderExtensions
{
///
/// Get the capabilities of the model used by the configured provider.
///
/// The configured provider.
/// The capabilities of the configured model.
public static List GetModelCapabilities(this Provider provider)
{
var automaticCapabilities = provider.UsedLLMProvider.GetModelCapabilities(provider.Model);
return provider.CapabilityOverrides?.ApplyTo(automaticCapabilities) ?? automaticCapabilities;
}
///
/// Get whether the model used by the configured provider accepts images as input.
///
///
/// Two capabilities express image input, one for a single image and one for several. Anything that
/// wants to know whether an image may be sent has to accept both, which is why the question is asked
/// here instead of at each call site: attaching a file and validating an already attached file must
/// never disagree about it.
///
/// The configured provider.
/// true when the model accepts image input.
public static bool SupportsImageInput(this Provider provider)
{
var capabilities = provider.GetModelCapabilities();
return capabilities.Contains(Capability.SINGLE_IMAGE_INPUT) || capabilities.Contains(Capability.MULTIPLE_IMAGE_INPUT);
}
///
/// Get the capabilities of a model for a specific provider.
///
/// The LLM provider.
/// The model to get the capabilities for.
/// >The capabilities of the model.
public static List GetModelCapabilities(this LLMProviders provider, Model model)
{
if (string.IsNullOrWhiteSpace(model.Id))
return [];
return provider switch
{
LLMProviders.OPEN_AI => GetModelCapabilitiesOpenAI(model),
LLMProviders.MISTRAL => GetModelCapabilitiesMistral(model),
LLMProviders.ANTHROPIC => GetModelCapabilitiesAnthropic(model),
LLMProviders.GOOGLE => GetModelCapabilitiesGoogle(model),
LLMProviders.X => GetModelCapabilitiesOpenSource(model),
LLMProviders.DEEP_SEEK => GetModelCapabilitiesDeepSeek(model),
LLMProviders.ALIBABA_CLOUD => GetModelCapabilitiesAlibaba(model),
LLMProviders.PERPLEXITY => GetModelCapabilitiesPerplexity(model),
LLMProviders.OPEN_ROUTER => GetModelCapabilitiesOpenRouter(model),
LLMProviders.GROQ => GetModelCapabilitiesOpenSource(model),
LLMProviders.FIREWORKS => GetModelCapabilitiesOpenSource(model),
LLMProviders.HUGGINGFACE => GetModelCapabilitiesOpenSource(model),
LLMProviders.HELMHOLTZ => GetModelCapabilitiesOpenSource(model),
LLMProviders.GWDG => GetModelCapabilitiesOpenSource(model),
LLMProviders.SELF_HOSTED => GetModelCapabilitiesOpenSource(model),
_ => []
};
}
}