31 lines
932 B
C#
31 lines
932 B
C#
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);
|
|
}
|
|
}
|
|
} |