iconsulting/packages/services/conversation-service
hailin 849a4a3099 feat(conversation): add token usage tracking for API cost analysis
- Add TokenUsageEntity to store per-request token consumption
- Add TokenUsageService with cost calculation and statistics APIs
  - Record input/output/cache tokens per API call
  - Calculate estimated cost based on Claude pricing
  - Provide user/conversation/global stats aggregation
  - Support daily stats and top users ranking
- Integrate token tracking in ClaudeAgentService
  - Track latency, tool calls, response length
  - Accumulate tokens across tool loop iterations
- Add token_usages table to init-db.sql with proper indexes

This enables:
- Per-user token consumption tracking
- Cost analysis and optimization
- Future billing/quota features

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 08:23:58 -08:00
..
src feat(conversation): add token usage tracking for API cost analysis 2026-01-23 08:23:58 -08:00
Dockerfile fix: 使用jq正确处理package.json移除workspace依赖 2026-01-09 08:49:41 -08:00
nest-cli.json Initial commit: iConsulting 香港移民咨询智能客服系统 2026-01-09 00:01:12 -08:00
package.json refactor: simplify Anthropic client config using baseURL 2026-01-09 20:45:44 -08:00
tsconfig.json Initial commit: iConsulting 香港移民咨询智能客服系统 2026-01-09 00:01:12 -08:00