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 #607

Merged
merged 1 commit into from
Dec 24, 2024
Merged

Feat/add bot token usage #607

merged 1 commit into from
Dec 24, 2024

Conversation

RaoHai
Copy link
Contributor

@RaoHai RaoHai commented Dec 24, 2024

No description provided.

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 24, 2024 3:28am

Copy link

Walkthrough

This pull request introduces a new feature to analyze bot token usage. It adds a new SQL function to calculate token usage statistics and updates the data access and service layers to support this functionality. Additionally, a new API endpoint is added to retrieve these statistics.

Changes

File Summary
migrations/supabase/migrations/20241224030938_remote_schema.sql Adds a SQL function analyze_user_token_usage to calculate token usage statistics.
server/core/dao/userTokenUsageDAO.py Implements a method to call the new SQL function and return the results.
server/core/models/user_token_usage.py Introduces BotTokenUsageStats model to represent the token usage data.
server/core/service/user_token_usage.py Adds a service method to analyze token usage.
server/user/router.py Adds a new API endpoint /llm_token_usages/analyzer to expose the token usage analysis functionality.

"end_date": end_date.strftime("%Y-%m-%d"),
}).execute()

return [BotTokenUsageStats(**stats) for stats in resp.data]

Choose a reason for hiding this comment

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

Ensure that resp.data is not None before iterating over it to prevent potential runtime errors. Consider adding a check or handling for this scenario.

Copy link
Contributor

@xingwanying xingwanying left a comment

Choose a reason for hiding this comment

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

LG

@RaoHai RaoHai merged commit 6f2bb56 into main Dec 24, 2024
3 of 4 checks passed
@RaoHai RaoHai deleted the feat/add-bot-token-usage branch December 24, 2024 03:39
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