petercat-ai / petercat

A conversational Q&A agent configuration system, self-hosted deployment solutions, and a convenient all-in-one application SDK, allowing you to create intelligent Q&A bots for your GitHub repositories
https://petercat.ai
MIT License
605 stars 18 forks source link

feat: add token usage facade #377

Closed RaoHai closed 2 months ago

RaoHai commented 2 months ago
vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
petercat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2024 2:39am
petercat-assistant[bot] commented 2 months ago

Walkthrough

增加了一个新的 token 用量统计接口,提供了统计用户在特定时间范围内的 token 使用情况的功能。

Changes

文件路径 摘要
migrations/supabase/migrations/20240912023152_remote_schema.sql 新增了一个用于获取用户统计数据的 SQL 函数。
server/core/dao/userTokenUsageDAO.py 添加了一个 stats 方法,通过调用 SQL 函数获取用户统计数据。
server/core/models/user_token_usage.py 新增了 UserTokenUsageStats 模型,用于表示 token 使用统计数据。
server/core/service/user_token_usage.py 新增了 UserTokenUsageService 服务类,提供获取用户 token 使用统计数据的方法。
server/user/router.py 在 API 路由中新增了一个端点,用于获取用户的 token 使用统计数据。
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 72.00000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/core/service/user_token_usage.py 66.66% 3 Missing :warning:
server/core/dao/userTokenUsageDAO.py 60.00% 2 Missing :warning:
server/user/router.py 66.66% 2 Missing :warning:
Files with missing lines Coverage Δ
server/core/models/user_token_usage.py 100.00% <100.00%> (ø)
server/core/dao/userTokenUsageDAO.py 66.66% <60.00%> (-6.07%) :arrow_down:
server/user/router.py 62.50% <66.66%> (+3.24%) :arrow_up:
server/core/service/user_token_usage.py 54.28% <66.66%> (+4.28%) :arrow_up: