* Extended functionalities

* Added different UIs
This commit is contained in:
2026-06-24 21:43:40 +02:00
parent 282f4864c4
commit f15bb7a916
348 changed files with 59057 additions and 498 deletions

View File

@@ -0,0 +1,44 @@
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;
/// <summary>Fallback when a task-specific model is not set.</summary>
public string Model { get; set; } = "gpt-4.1-mini";
/// <summary>Macro target refinement (diet generator step 2).</summary>
public string? MacrosModel { get; set; }
/// <summary>Weekly meal plan recipe selection (diet generator step 3).</summary>
public string? PlanModel { get; set; }
/// <summary>AI recipe draft generation and partial regen.</summary>
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;
}