Private
Public Access
1
0

Add AI chat with Ollama tool calling for financial queries

Conversational AI chat that uses Ollama's native tool-calling API to query
transactions, spending reports, account balances, dashboard summaries, and
update transaction categories through natural language. Includes persistent
conversation history, a full-page chat UI with sidebar, and rich inline
rendering of tool results (tables, alerts, cards).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Catherine Renelle
2026-02-09 23:34:16 -05:00
parent 1ceeca0fb6
commit 846edad2a4
20 changed files with 3237 additions and 0 deletions
@@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Purrse.Core.DTOs;
using Purrse.Core.Interfaces.Services;
using System.Security.Claims;
namespace Purrse.Api.Controllers;
[Authorize]
[ApiController]
[Route("api/[controller]")]
public class ChatController : ControllerBase
{
private readonly IChatService _chatService;
private Guid UserId => Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
public ChatController(IChatService chatService) => _chatService = chatService;
[HttpPost("send")]
public async Task<ActionResult<SendChatMessageResponse>> SendMessage(SendChatMessageRequest request)
=> Ok(await _chatService.SendMessageAsync(UserId, request));
[HttpGet("conversations")]
public async Task<ActionResult<List<ChatConversationResponse>>> GetConversations()
=> Ok(await _chatService.GetConversationsAsync(UserId));
[HttpGet("conversations/{id}")]
public async Task<ActionResult<ChatConversationDetailResponse>> GetConversation(Guid id)
{
var conversation = await _chatService.GetConversationAsync(UserId, id);
return conversation == null ? NotFound() : Ok(conversation);
}
[HttpDelete("conversations/{id}")]
public async Task<ActionResult> DeleteConversation(Guid id)
{
await _chatService.DeleteConversationAsync(UserId, id);
return NoContent();
}
}