From 3aba01d56aface1ba95e27ce595720d2d63bdbd4 Mon Sep 17 00:00:00 2001 From: Jeas0001 Date: Thu, 1 May 2025 09:36:36 +0200 Subject: [PATCH] Generate recieve a json object and is a post request now --- backend/API/Controllers/RecipeController.cs | 6 +++--- backend/API/Models/RecipeModels/GenerateRecipeDTO.cs | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 backend/API/Models/RecipeModels/GenerateRecipeDTO.cs diff --git a/backend/API/Controllers/RecipeController.cs b/backend/API/Controllers/RecipeController.cs index 2699f1e..bd65528 100644 --- a/backend/API/Controllers/RecipeController.cs +++ b/backend/API/Controllers/RecipeController.cs @@ -62,10 +62,10 @@ namespace API.Controllers } [Authorize] - [HttpGet("chatbot/{dish}")] - public async Task GenerateRecipe(string dish, string language, int numberOfRecipes = 5) + [HttpPost("chatbot")] + public async Task GenerateRecipe([FromBody] GenerateRecipeDTO recipeDTO) { - var recipes = await _openAiRecipes.ChatGPT(dish, language, numberOfRecipes); + var recipes = await _openAiRecipes.ChatGPT(recipeDTO.Dish, recipeDTO.Language, recipeDTO.NumberOfRecipes); if (recipes.Content[0].Text == null || recipes.Content[0].Text == "") { return new ConflictObjectResult(new { message = "Could not connect to chatGPT" }); diff --git a/backend/API/Models/RecipeModels/GenerateRecipeDTO.cs b/backend/API/Models/RecipeModels/GenerateRecipeDTO.cs new file mode 100644 index 0000000..6d869b5 --- /dev/null +++ b/backend/API/Models/RecipeModels/GenerateRecipeDTO.cs @@ -0,0 +1,11 @@ +namespace API.Models.RecipeModels +{ + public class GenerateRecipeDTO + { + public string Dish { get; set; } + + public string Language { get; set; } + + public int NumberOfRecipes { get; set; } = 5; + } +}