BG Cost management

BG Cost management

The purpose of this module is to manage the costs of AI consumption for both. quarries and the embeddings

The analysis BL/ ingestor BL components will be the one updating both tables

Tables

Table : AI_USAGE_HISTORY

 

Name

Type

Comments

Name

Type

Comments

RequestID

 

The unique identifier of the request

RequestType

 

Summary, Tasks, Query , Embedding

UserUPN

 

The user principal name of the requester. Can be used to get the account from BG USERS

RequestPromptTokenCount

 

The number of tokens in the request prompt

RequestCompletionTokenCount

 

The number of tokens in the request completion

RequestCostUSD

 

The cost of the request in US dollars. Calcualted by our code (hard coded as for Oct 2023)

RequestDate

 

The date of the request

RequestSourceType

 

Chat

RequestSourceId

 

ID of the RequestSourceType

 

Table: AI_USAGE_COST

Name

Type

Comments

Name

Type

Comments

UserUPN

 

The user principal name of the user

CurrentMonthUsageUSD

 

The amount of usage in US dollars for the current month

MonthlyUsageLimitUSD

 

The limit of usage in US dollars for the current month

LastUsageUpdateTime

 

The last time the usage was updated

SubscriptionStartDate

 

When user started using the subscription

For every new users when someone asks a question, the analysis BL adds a record to this table with the MonthlyUsageLimitUSD taken from the general setting table

Dashboard UI

 

Under the menu item of “User settings,” the user will be able to see a new page named: “Usage”

The page will show at the top:
Total monthly costs is X$ from the limit of Y$. Show bar.

Also add detailed list displaying all the records from AI_USAGE_HISTORY with option to export to Excel.

 

In the Dashbaord, on every activity - need to check if user has passed the limit and display message if needed “It seems that you have run out of budget of AI tokens. Please contact support@agatsoftware.com

Operation is - new content or asking questions.