diff --git a/src/MyRecipes.API/BackgroudServices/DeleteUserService.cs b/src/MyRecipes.API/BackgroudServices/DeleteUserService.cs index e2efa93..bb78b21 100644 --- a/src/MyRecipes.API/BackgroudServices/DeleteUserService.cs +++ b/src/MyRecipes.API/BackgroudServices/DeleteUserService.cs @@ -37,13 +37,4 @@ private async Task ProcessMessageAsync(ProcessMessageEventArgs eventArgs) } private static Task ExceptionReceivedHandler(ProcessErrorEventArgs _) => Task.CompletedTask; - - ~DeleteUserService() => Dispose(); - - public override void Dispose() - { - base.Dispose(); - - GC.SuppressFinalize(this); - } } diff --git a/src/MyRecipes.Application/UseCases/Recipe/Generate/GenerateRecipeValidator.cs b/src/MyRecipes.Application/UseCases/Recipe/Generate/GenerateRecipeValidator.cs index 834061d..dd80249 100644 --- a/src/MyRecipes.Application/UseCases/Recipe/Generate/GenerateRecipeValidator.cs +++ b/src/MyRecipes.Application/UseCases/Recipe/Generate/GenerateRecipeValidator.cs @@ -1,4 +1,5 @@ using FluentValidation; + using MyRecipes.Communication.Requests; using MyRecipes.Domain.ValueObjects; using MyRecipes.Exceptions; @@ -31,7 +32,6 @@ public GenerateRecipeValidator() if (value.Count(c => c == ' ') > 3 || value.Count(c => c == '/') > 1) { context.AddFailure("Ingredient", ResourceMessagesExceptions.INGREDIENT_NOT_FOLLOWING_PATTERN); - return; } }); }); diff --git a/src/MyRecipes.Infrastructure/DependencyInjectionExtension.cs b/src/MyRecipes.Infrastructure/DependencyInjectionExtension.cs index 04cb248..4fe0fb2 100644 --- a/src/MyRecipes.Infrastructure/DependencyInjectionExtension.cs +++ b/src/MyRecipes.Infrastructure/DependencyInjectionExtension.cs @@ -109,11 +109,10 @@ private static void AddPasswordEncripter(IServiceCollection services) private static void AddOpenAI(IServiceCollection services, IConfiguration configuration) { - const string CHAT_MODEL = "gpt-4o"; var apiKey = configuration.GetValue("Settings:OpenAI:ApiKey"); - services.AddScoped(); - services.AddScoped(_ => new ChatClient(model: CHAT_MODEL, apiKey: apiKey)); + services.AddScoped(); + services.AddScoped(_ => new ChatClient(model: "gpt-4o", apiKey: apiKey)); } private static void AddStorage(IServiceCollection services, IConfiguration configuration) diff --git a/src/MyRecipes.Infrastructure/Services/OpenAI/ChatGPTService.cs b/src/MyRecipes.Infrastructure/Services/OpenAI/ChatGPTService.cs index 32c5620..19c7c1e 100644 --- a/src/MyRecipes.Infrastructure/Services/OpenAI/ChatGPTService.cs +++ b/src/MyRecipes.Infrastructure/Services/OpenAI/ChatGPTService.cs @@ -1,14 +1,15 @@ using MyRecipes.Domain.Dtos; using MyRecipes.Domain.Enums; using MyRecipes.Domain.Services.OpenAi; + using OpenAI.Chat; namespace MyRecipes.Infrastructure.Services.OpenAI; -internal class ChatGPTService : IGenerateRecipeAI +internal class ChatGptService : IGenerateRecipeAI { private readonly ChatClient _chatClient; - public ChatGPTService(ChatClient chatClient) => _chatClient = chatClient; + public ChatGptService(ChatClient chatClient) => _chatClient = chatClient; public async Task Generate(IList ingredients) { @@ -18,7 +19,7 @@ public async Task Generate(IList ingredients) new UserChatMessage(string.Join(';', ingredients)) ]; - var completion = await _chatClient.CompleteChatAsync(); + var completion = await _chatClient.CompleteChatAsync(messages); var responseList = completion.Value.Content[0].Text .Split("\n")