Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add bot token usage #609

Merged
merged 8 commits into from
Dec 25, 2024
Merged

Feat/add bot token usage #609

merged 8 commits into from
Dec 25, 2024

Conversation

RaoHai
Copy link
Contributor

@RaoHai RaoHai commented Dec 24, 2024

image

Copy link

vercel bot commented Dec 24, 2024

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 Dec 25, 2024 3:56am

Copy link

Walkthrough

This pull request introduces a new feature for analyzing bot token usage. It adds a new admin page to display token usage statistics, including input and output tokens, top bots, and top users. The implementation includes new hooks, services, and database functions to support these analytics.

Changes

Files Summary
client/app/admin/page.tsx Added a new admin page component to display token usage statistics using charts and progress bars.
client/app/hooks/useAnalyze.ts Introduced hooks to fetch token usage, top bots, and top users data.
client/app/services/TokensController.ts Added functions to call API endpoints for token usage analysis.
migrations/supabase/migrations/20241224095717_remote_schema.sql Added SQL functions to calculate token usage rates and updated the profiles table.
server/core/dao/userTokenUsageDAO.py Implemented methods to interact with the new SQL functions for token usage rates.
server/core/models/user_token_usage.py Added new data models for token usage statistics and rates.
server/core/service/user_token_usage.py Added service methods to retrieve top bots and users.
server/user/router.py Updated API routes to include endpoints for top bots and users.
client/package.json, client/yarn.lock Updated dependencies to support new features.

color="primary"
formatOptions={{ style: "decimal"}}
label={record.user_name}
maxValue={maxBy(topBots, 'total_tokens')?.total_tokens}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that maxBy(topBots, 'total_tokens')?.total_tokens is not undefined before using it as maxValue. Consider providing a default value to avoid potential runtime errors.

Copy link

codecov bot commented Dec 24, 2024

Codecov Report

Attention: Patch coverage is 40.90909% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/auth/router.py 22.22% 7 Missing ⚠️
server/core/service/user_token_usage.py 40.00% 3 Missing ⚠️
server/core/dao/profilesDAO.py 33.33% 2 Missing ⚠️
server/core/dao/userTokenUsageDAO.py 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
server/auth/clients/auth0.py 46.93% <ø> (ø)
server/auth/clients/local.py 57.69% <ø> (ø)
server/core/models/user.py 100.00% <ø> (ø)
server/core/models/user_token_usage.py 100.00% <100.00%> (ø)
server/user/router.py 62.85% <100.00%> (+0.35%) ⬆️
server/core/dao/userTokenUsageDAO.py 61.11% <50.00%> (-5.56%) ⬇️
server/core/dao/profilesDAO.py 38.09% <33.33%> (ø)
server/core/service/user_token_usage.py 48.78% <40.00%> (+0.06%) ⬆️
server/auth/router.py 37.97% <22.22%> (ø)

... and 2 files with indirect coverage changes

@RaoHai RaoHai merged commit 4d7240b into main Dec 25, 2024
4 of 5 checks passed
@RaoHai RaoHai deleted the feat/add-bot-token-usage branch December 25, 2024 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants