Implement AI

This commit is contained in:
Chris Chen
2026-06-25 11:11:26 -07:00
parent fa3e75a333
commit a89e936f4d
11 changed files with 377 additions and 5 deletions
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ROLAC.API.DTOs.Expense;
using ROLAC.API.Services.Ai;
namespace ROLAC.API.Controllers;
[ApiController]
[Route("api/expense-ai")]
[Authorize] // Open to any authenticated user — same audience as the expense-entry form, which any
// member filing a reimbursement can reach. The endpoint only reads the category catalog.
public class ExpenseAiController : ControllerBase
{
private readonly IExpenseAiService _svc;
public ExpenseAiController(IExpenseAiService svc) => _svc = svc;
[HttpPost("assist")]
public async Task<IActionResult> Assist([FromBody] ExpenseAiAssistRequest request, CancellationToken ct)
{
if (string.IsNullOrWhiteSpace(request.Text))
return BadRequest("Text is required.");
var suggestion = await _svc.SuggestAsync(request.Text, request.Amount, ct);
return Ok(suggestion);
}
}