using LLMApi.Data.Contracts.ChatGpt3_5; using LLMApi.Data.Contracts.Game.ChatGpt3_5; using LLMApi.Services; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; namespace LLMApi.Controllers; [ApiController] [Route("[controller]")] public class LLMController : ControllerBase { private readonly ILlmApiService _apiService; public LLMController(ILlmApiService apiService) { _apiService = apiService; } // [HttpGet(nameof(AnswerToPrompt))] // public async Task> AnswerToPrompt(string prompt = "Hello!") // { // try // { // var choices = await _apiService.GetAnswerToPrompt(prompt); // return Ok(choices); // } // catch (Exception ex) // { // _logger.LogError(ex, null, Array.Empty()); // return StatusCode(500, ex.ToString()); // } // } [HttpGet(nameof(Answer))] public async Task> Answer(AnswerRequest answerRequest) { try { System.Console.WriteLine(JsonConvert.SerializeObject(answerRequest)); System.Console.WriteLine(">"); var answerResponse = await _apiService.GetAnswer(answerRequest); System.Console.WriteLine(JsonConvert.SerializeObject(answerResponse)); System.Console.WriteLine(); System.Console.WriteLine(); return Ok(answerResponse); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return StatusCode(500, ex.ToString()); } } }