From 9c1f850ee08b33fa7a1e91626081f2d09f4b8fcb Mon Sep 17 00:00:00 2001 From: Martin Mark Date: Fri, 20 Dec 2024 10:43:56 -0500 Subject: [PATCH] Token and cost formatting --- .../Home/Browse3/pages/CallPage/cost/costUtils.ts | 13 ++----------- .../Browse3/pages/CallsPage/callsTableColumns.tsx | 4 ++++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallPage/cost/costUtils.ts b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallPage/cost/costUtils.ts index 0151016bb276..ec6d464752ae 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallPage/cost/costUtils.ts +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallPage/cost/costUtils.ts @@ -66,12 +66,8 @@ export const FORMAT_NUMBER_NO_DECIMALS = new Intl.NumberFormat('en-US', { // Number formatting function that formats numbers in the thousands and millions with 3 sigfigs export const formatTokenCount = (num: number): string => { - if (num < 10000) { + if (num < 1000000) { return FORMAT_NUMBER_NO_DECIMALS.format(num); - } else if (num >= 10000 && num < 1000000) { - // Format numbers in the thousands - const thousands = (num / 1000).toFixed(1); - return parseFloat(thousands).toString() + 'k'; } // Format numbers in the millions const millions = (num / 1000000).toFixed(2); @@ -79,12 +75,7 @@ export const formatTokenCount = (num: number): string => { }; export const formatTokenCost = (cost: number): string => { - if (cost === 0) { - return '$0.00'; - } else if (cost < 0.01) { - return '$<0.01'; - } - return `$${cost.toFixed(2)}`; + return `$${cost.toFixed(4)}`; }; // TODO(Josiah): this is here because sometimes the cost query is not returning all the ids I believe for unfinished calls, diff --git a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/callsTableColumns.tsx b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/callsTableColumns.tsx index 93bd2ee030b1..ca71e2eaaa27 100644 --- a/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/callsTableColumns.tsx +++ b/weave-js/src/components/PagePanelComponents/Home/Browse3/pages/CallsPage/callsTableColumns.tsx @@ -441,6 +441,8 @@ function buildCallsTableColumns( width: 100, minWidth: 100, maxWidth: 100, + align: 'right', + headerAlign: 'right', // Should probably have a custom filter here. filterable: false, sortable: false, @@ -463,6 +465,8 @@ function buildCallsTableColumns( width: 100, minWidth: 100, maxWidth: 100, + align: 'right', + headerAlign: 'right', // Should probably have a custom filter here. filterable: false, sortable: false,