feat: enhance LLM response handling and token usage tracking in chat services and UI components

This commit is contained in:
Anish Sarkar 2026-04-14 15:29:02 +05:30
parent 5510c1de03
commit f21bdc0668
4 changed files with 67 additions and 37 deletions

View file

@ -4,6 +4,10 @@ Token usage tracking via LiteLLM custom callback.
Uses a ContextVar-scoped accumulator to group all LLM calls within a single
async request/turn. The accumulated data is emitted via SSE and persisted
when the frontend calls appendMessage.
Agent LLM calls are captured automatically via the async callback.
Title-generation usage is added explicitly from the LangChain response
metadata to avoid callback-timing issues.
"""
from __future__ import annotations