-
Notifications
You must be signed in to change notification settings - Fork 7
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
Track credit consumption in AI bot #1809
Conversation
As an interesting observation, when users simply say "hello" to the bot, the response will cost them around 1-3 credits, sometimes up to 5. For editing cards, and for longer responses, this cost can go up to 10-15 or more. So it looks like free plan users (100 credits) will be able to only have a couple interactions with the free plan's allowance. |
subscriptionCycleId: subscriptionCycle.id, | ||
}); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be worth tracking the generation ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now with this simple variant this may not be necessary but later on when we introduce jobs and queues, we could save the generation id there (in the serialized job) and have it available for inspection if needed.
This PR adds a mechanism to AI bot which tracks the AI-related cost, where it fetches the dollar cost from OpenRouter after ai bot streaming is done, converts to credits and writes it to the credit ledger.
Below is an example how the credits ledger looks like after a couple of interactions with the AI bot. You can see that it first tries to spend the plan's allowance credits, and when that's gone it spends the extra credits: