mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix cost calculation, improve display
This commit is contained in:
3 files changed
+5
-7
No files matched your search
@@ -443,7 +443,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
{/* Bottom Controls Row */}
|
||||
<div className="absolute bottom-2 left-2 right-2 flex items-center gap-2">
|
||||
{/* Context Usage Wheel */}
|
||||
{currentModel?.contextLength && lastInputTokens > 0 && (
|
||||
{contextUsagePercentage >= 10 && currentModel?.contextLength && lastInputTokens > 0 && (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
@@ -463,12 +463,12 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
||||
)}
|
||||
|
||||
{/* Cost Display */}
|
||||
{totalCost > 0 && (
|
||||
{totalCost >= 0.01 && (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="text-xs text-muted-foreground px-2 py-1 bg-muted/50 rounded-md whitespace-nowrap cursor-help">
|
||||
${totalCost < 0.01 ? totalCost.toFixed(6) : totalCost.toFixed(4)}
|
||||
${totalCost.toFixed(2)}
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
|
||||
@@ -56,8 +56,6 @@ export function useProviderModels(): ModelFetchResult {
|
||||
signal: AbortSignal.timeout(10_000),
|
||||
});
|
||||
|
||||
console.log(response);
|
||||
|
||||
// Transform models to our format
|
||||
const providerModels = response.data.map((model) => {
|
||||
const providerModel: ProviderModel = {
|
||||
|
||||
@@ -518,8 +518,8 @@ export class SessionManager {
|
||||
}
|
||||
|
||||
// Calculate cost for this request
|
||||
const promptCost = model.pricing.prompt.mul(usage.prompt_tokens).div(1000); // pricing is per 1k tokens
|
||||
const completionCost = model.pricing.completion.mul(usage.completion_tokens).div(1000);
|
||||
const promptCost = model.pricing.prompt.times(usage.prompt_tokens);
|
||||
const completionCost = model.pricing.completion.times(usage.completion_tokens);
|
||||
const requestCost = promptCost.add(completionCost).toNumber();
|
||||
|
||||
// Update session total cost
|
||||
|
||||
Reference in new issue
Block a user