namespace GermanApp.Infrastructure.Configuration;
///
/// Configuration settings for Mistral API connector.
/// This is part of the Infrastructure layer.
///
public class MistralConfig
{
///
/// The Mistral API key for authentication.
///
public string ApiKey { get; set; } = string.Empty;
///
/// The base URL for the Mistral API.
/// Default: https://api.mistral.ai/v1/
///
public string BaseUrl { get; set; } = "https://api.mistral.ai/v1/";
///
/// The default model to use for completions.
/// Default: mistral-small-latest
///
public string DefaultModel { get; set; } = "mistral-small-latest";
///
/// Timeout in seconds for HTTP requests.
/// Default: 30 seconds
///
public int TimeoutSeconds { get; set; } = 30;
///
/// Maximum number of retry attempts for failed requests.
/// Default: 3
///
public int MaxRetries { get; set; } = 3;
///
/// Maximum requests per minute rate limit.
/// Default: 10 requests/minute
///
public int RateLimitPerMinute { get; set; } = 10;
///
/// Whether to enable response caching.
/// Default: true
///
public bool EnableCaching { get; set; } = true;
///
/// Cache time-to-live in minutes.
/// Default: 60 minutes
///
public int CacheTTLMinutes { get; set; } = 60;
///
/// Circuit breaker failure threshold (number of consecutive failures before opening).
/// Default: 5
///
public int CircuitBreakerFailureThreshold { get; set; } = 5;
///
/// Circuit breaker reset timeout in minutes.
/// Default: 1 minute
///
public int CircuitBreakerResetMinutes { get; set; } = 1;
///
/// Validates the configuration.
///
/// Thrown when configuration is invalid
public void Validate()
{
if (string.IsNullOrWhiteSpace(ApiKey))
{
throw new ArgumentException("Mistral API key is required");
}
if (string.IsNullOrWhiteSpace(BaseUrl))
{
throw new ArgumentException("Mistral BaseUrl is required");
}
if (!Uri.TryCreate(BaseUrl, UriKind.Absolute, out _))
{
throw new ArgumentException("Mistral BaseUrl must be a valid URL");
}
if (TimeoutSeconds <= 0)
{
throw new ArgumentException("TimeoutSeconds must be greater than 0");
}
if (MaxRetries < 0)
{
throw new ArgumentException("MaxRetries must be non-negative");
}
if (RateLimitPerMinute <= 0)
{
throw new ArgumentException("RateLimitPerMinute must be greater than 0");
}
if (CacheTTLMinutes < 0)
{
throw new ArgumentException("CacheTTLMinutes must be non-negative");
}
if (CircuitBreakerFailureThreshold <= 0)
{
throw new ArgumentException("CircuitBreakerFailureThreshold must be greater than 0");
}
if (CircuitBreakerResetMinutes <= 0)
{
throw new ArgumentException("CircuitBreakerResetMinutes must be greater than 0");
}
}
}