Generate recieve a json object and is a post request now

This commit is contained in:
Jeas0001 2025-05-01 09:36:36 +02:00
parent fac4e04c2c
commit 3aba01d56a
2 changed files with 14 additions and 3 deletions

View File

@ -62,10 +62,10 @@ namespace API.Controllers
}
[Authorize]
[HttpGet("chatbot/{dish}")]
public async Task<IActionResult> GenerateRecipe(string dish, string language, int numberOfRecipes = 5)
[HttpPost("chatbot")]
public async Task<IActionResult> 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" });

View File

@ -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;
}
}