namespace MealPlan.Api.Services.AI; public enum OpenAiUseCase { Default, Macros, Plan, Recipe, } public class OpenAiOptions { public const string SectionName = "OpenAI"; public string ApiKey { get; set; } = string.Empty; /// Fallback when a task-specific model is not set. public string Model { get; set; } = "gpt-4.1-mini"; /// Macro target refinement (diet generator step 2). public string? MacrosModel { get; set; } /// Weekly meal plan recipe selection (diet generator step 3). public string? PlanModel { get; set; } /// AI recipe draft generation and partial regen. public string? RecipeModel { get; set; } public int MaxTokens { get; set; } = 4096; public bool IsConfigured => !string.IsNullOrWhiteSpace(ApiKey); public string ResolveModel(OpenAiUseCase useCase) => useCase switch { OpenAiUseCase.Macros => FirstNonEmpty(MacrosModel, Model), OpenAiUseCase.Plan => FirstNonEmpty(PlanModel, Model), OpenAiUseCase.Recipe => FirstNonEmpty(RecipeModel, Model), _ => Model, }; private static string FirstNonEmpty(string? preferred, string fallback) => string.IsNullOrWhiteSpace(preferred) ? fallback : preferred; }