ChatController.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using HTEXGpt.Models;
  2. using HTEXGpt.Services;
  3. using Microsoft.AspNetCore.Mvc;
  4. using System.Diagnostics.Tracing;
  5. using System.Net;
  6. namespace HTEXGpt.Controllers
  7. {
  8. [ProducesResponseType(StatusCodes.Status200OK)]
  9. [ProducesResponseType(StatusCodes.Status400BadRequest)]
  10. [Route("chat")]
  11. [ApiController]
  12. public class ChatController:ControllerBase
  13. {
  14. private static int _eventCounter = 0;
  15. private readonly IAiAppService _aiAppService;
  16. public ChatController(IAiAppService aiAppService) {
  17. _aiAppService=aiAppService;
  18. }
  19. /// <summary>
  20. /// 混元大模型
  21. /// SecretId:AKIDthPvHSSEnCTXNyVfjfWCvZVNLNJ8lBXi
  22. ///SecretKey:CKKA0e7MROFyY1JPQMD90kLl1JXnw20n
  23. /// </summary>
  24. /// <param name="dto"></param>
  25. /// <returns></returns>
  26. [HttpPost("message")]
  27. public async Task<IActionResult > Message(ChatRequest dto) {
  28. var chatResponse = await _aiAppService.ChatMessage(dto.modelType, dto, HttpContext, Response);
  29. return Ok(new { response = chatResponse });
  30. }
  31. }
  32. }