Organize workspace: Frontend, Backend, and Tests in one repo

This commit is contained in:
2026-03-04 22:04:07 +00:00
parent a24e901b7f
commit c065cbf61e
5390 changed files with 844081 additions and 446 deletions

View File

@@ -0,0 +1,52 @@
using Seasoned.Backend.DTOs;
using Mscc.GenerativeAI;
namespace Seasoned.Backend.Services;
public class RecipeService : IRecipeService
{
private readonly string _apiKey;
public RecipeService(IConfiguration config)
{
_apiKey = config["GeminiApiKey"] ?? throw new ArgumentNullException("API Key missing");
}
public async Task<RecipeResponseDto> ParseRecipeImageAsync(IFormFile image)
{
var googleAI = new GoogleAI(_apiKey);
var model = googleAI.GenerativeModel("gemini-2.5-flash");
using var ms = new MemoryStream();
await image.CopyToAsync(ms);
var base64Image = Convert.ToBase64String(ms.ToArray());
var prompt = "Extract the recipe from this image. Return Title and Description.";
// Explicitly typed request object
GenerateContentRequest request = new()
{
Contents = new List<Content>
{
new Content
{
Parts = new List<Part>
{
new() { Text = prompt },
new() { InlineData = new InlineData { MimeType = "image/png", Data = base64Image } }
}
}
}
};
var response = await model.GenerateContent((GenerateContentRequest)request);
return new RecipeResponseDto
{
Title = "Gemini 2.5 Analysis",
Description = response.Text ?? "No text returned",
Ingredients = new List<string>(),
Instructions = new List<string>()
};
}
}