Files

31 lines
932 B
C#
Raw Permalink Normal View History

2025-12-09 10:28:18 -03:00
using Microsoft.AspNetCore.Mvc;
using ChatbotApi.Data.Models;
using Microsoft.AspNetCore.RateLimiting;
using System.Runtime.CompilerServices;
using ChatbotApi.Services;
namespace ChatbotApi.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class ChatController : ControllerBase
{
private readonly IChatService _chatService;
private readonly ILogger<ChatController> _logger;
public ChatController(IChatService chatService, ILogger<ChatController> logger)
{
_chatService = chatService;
_logger = logger;
}
[HttpPost("stream-message")]
[EnableRateLimiting("fixed")]
public IAsyncEnumerable<string> StreamMessage(
[FromBody] ChatRequest request,
CancellationToken cancellationToken)
{
return _chatService.StreamMessageAsync(request, cancellationToken);
}
}
}