-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Create a usage schema that records user's usage. One user should have multiple usages (One usage per chat) including token usage and usage in dollar. It also records the model it uses. The usage is coming from the model, however, it only includes the token usage, and you neeed to use the selected model (which has the pricing for 1k tokens), then you need to multiply those numbers to get usage in USD per request.
For usage schema you need
- id - autogenerated
- created_at
- updated_at
- model name
- model provider
- token usage - json
- usd usage - number
- isPaid - boolean
- user - fk
In the query, you need to write the following queries:
- record usage by user with selected model
- get total usage by month (as input parameter)
- get list of usages order by time and paginated
- isOverlimit (gather all unpaid usage and check if it over the user's usage limit by user comparing user's credit and web3Credit)
- get unPaidedUsage (show all unpaid usage paginated)
- payUsage will set the usage to be paid and deduct user's credit. If user's credit not enough to pay the credit, use web3's credit and deduct the web3Credit. This function takes two object, one is payInWeb2 and one is payInWeb3. Call these two functions for payment
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request