aws-samples / bedrock-claude-chat

AWS-native chatbot using Bedrock + Claude (+Mistral)
MIT No Attribution
687 stars 230 forks source link

[Feature Request] Precise cost calculation - /admin/shared-bot-analytics #385

Open statefb opened 1 week ago

statefb commented 1 week ago

Describe the solution you'd like

  1. tldr - it uses the local timezone where the backend is deployed, in our case is us-east-1 (N. Virginia / Eastern Daylight Time / GMT+4), which is very confusing for the users. They 100% don't care about the timezone, and expect it to just work for their timezone. Current implementation still works to grab the tendency of the usage, but it cannot reflect the actual usage.

  2. Long technical explanation - when a user uses a chatbot, their conversation log is stored in DynamoDB, along with their timestamp, and also the price estimation for that particular conversation (calculated using the method above). Both are calculated by Python 3.11 (get_current_time, and calculate_price). Python 3.11 uses local timezone by default, if parameters are not specified (like in our case). They then exported the DynamoDB table to an S3 bucket. The export job is done hourly by a combination of EventBridge + Lambda function. In the pricing estimation page, they use Athena to query the conversation log, and display them to the user.

Why the solution needed

To show precise usage for administrators.

Implementation feasibility

Are you willing to discuss the solution with us, decide on the approach, and assist with the implementation?