Split the logic for retrieving aggregated token usage into a separate method to facilitate reuse when returning prompt output data.
Updated the prompt output serializer's to_representation method to include token usage information.
Frontend:
Updated TokenUsage component to fetch and display token usage details based on tokenUsageId.
Implemented global state to persist token usage data.
-
Why
The token usage data was not persisted earlier.
-
How
The run_id was already available in the prompt output manager table. Using that run_id, the aggregated token usage information is retrieved and included in the response.
-
Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Yes, there is a possibility of affecting existing features since the prompt output manager has been modified to accommodate the token usage persistence changes.
-
Database Migrations
NA
Env Config
NA
Relevant Docs
NA
Related Issues or PRs
NA
Dependencies Versions
NA
Notes on Testing
NA
Screenshots
Multi Pass:
Coverage Modal:
Checklist
I have read and understood the [Contribution Guidelines]().
What
Backend:
to_representation
method to include token usage information.Frontend:
TokenUsage
component to fetch and display token usage details based ontokenUsageId
.-
Why
The token usage data was not persisted earlier.
-
How
The
run_id
was already available in the prompt output manager table. Using thatrun_id
, the aggregated token usage information is retrieved and included in the response.-
Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Yes, there is a possibility of affecting existing features since the prompt output manager has been modified to accommodate the token usage persistence changes.
-
Database Migrations
NA
Env Config
NA
Relevant Docs
NA
Related Issues or PRs
NA
Dependencies Versions
NA
Notes on Testing
NA
Screenshots
Multi Pass:![Screenshot from 2024-06-02 21-25-03](https://github.com/Zipstack/unstract/assets/89440263/20e5857b-4db9-44b0-a3b4-1bff1014a09d)
Coverage Modal:![Screenshot from 2024-06-02 21-25-10](https://github.com/Zipstack/unstract/assets/89440263/2cd7c860-e461-40e6-ae9b-43dda12b3ad2)
Checklist
I have read and understood the [Contribution Guidelines]().