* Extended functionalities
* Added different UIs
This commit is contained in:
44
MealPlan.Api/Services/AI/OpenAiOptions.cs
Normal file
44
MealPlan.Api/Services/AI/OpenAiOptions.cs
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user