Merge pull request #705 from chenyme/price

fix: update pricing calculations and improve tooltip display for bot risk
This commit is contained in:
Chenyme authored and GitHub committed 2026-07-19 12:11:55 +08:00
commit 2bd9d1a4e0
5 files changed
+21 -16

No files matched your search

+1 -1
View File
@@ -55,7 +55,7 @@ func buildOfficialTokenPrices() map[string]tokenPrice {
}
register("grok-build-0.1", tokenPrice{InputTicks: 10000, CachedInputTicks: 2000, OutputTicks: 20000, LongContextTokens: 200000, LongInputTicks: 20000, LongCachedTicks: 4000, LongOutputTicks: 40000},
"grok-code-fast-1", "grok-code-fast", "grok-code-fast-1-0825", "grok-composer-2.5-fast")
register("grok-4.5", tokenPrice{InputTicks: 20000, CachedInputTicks: 5000, OutputTicks: 60000, LongContextTokens: 200000, LongInputTicks: 40000, LongCachedTicks: 10000, LongOutputTicks: 120000},
register("grok-4.5", tokenPrice{InputTicks: 20000, CachedInputTicks: 3000, OutputTicks: 60000, LongContextTokens: 200000, LongInputTicks: 40000, LongCachedTicks: 6000, LongOutputTicks: 120000},
"grok-4.5-latest", "grok-build-latest")
standard := tokenPrice{InputTicks: 12500, CachedInputTicks: 2000, OutputTicks: 25000, LongContextTokens: 200000, LongInputTicks: 25000, LongCachedTicks: 4000, LongOutputTicks: 50000}
register("grok-4.3", standard, "grok-4.3-latest", "grok-latest")
@@ -12,7 +12,7 @@ func TestEstimateOfficialCostHandlesCacheAliasesAndLongContext(t *testing.T) {
t.Fatalf("composer result = %#v, ok = %v", result, ok)
}
result, ok = EstimateOfficialCost("grok-4.5", 1_000_000, 200_000, 500_000, 210_000)
if !ok || result.CostInUSDTicks != 94_000_000_000 {
if !ok || result.CostInUSDTicks != 93_200_000_000 {
t.Fatalf("long-context result = %#v, ok = %v", result, ok)
}
result, ok = EstimateOfficialCost("Web/grok-4.5-build-free", 100, 0, 50, 100)
@@ -53,7 +53,7 @@ func TestOfficialPricingMatchesPublishedTokenRates(t *testing.T) {
inputCost, cachedCost, outputCost int64
}{
{model: "grok-build-0.1", inputCost: 10_000_000_000, cachedCost: 2_000_000_000, outputCost: 20_000_000_000},
{model: "grok-4.5", inputCost: 20_000_000_000, cachedCost: 5_000_000_000, outputCost: 60_000_000_000},
{model: "grok-4.5", inputCost: 20_000_000_000, cachedCost: 3_000_000_000, outputCost: 60_000_000_000},
{model: "grok-4.3", inputCost: 12_500_000_000, cachedCost: 2_000_000_000, outputCost: 25_000_000_000},
{model: "grok-4.20-multi-agent-0309", inputCost: 12_500_000_000, cachedCost: 2_000_000_000, outputCost: 25_000_000_000},
{model: "grok-4.20-0309-reasoning", inputCost: 12_500_000_000, cachedCost: 2_000_000_000, outputCost: 25_000_000_000},
@@ -1,4 +1,4 @@
import { Compass, Handshake, SquareTerminal, VenusAndMars, Webhook, type LucideIcon } from "lucide-react";
import { Bot, Compass, Handshake, SquareTerminal, VenusAndMars, Webhook, type LucideIcon } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
@@ -59,14 +59,6 @@ export function AccountNameCell({ account }: { account: AccountDTO }) {
</TooltipTrigger>
<TooltipContent>{account.name}</TooltipContent>
</Tooltip>
{account.buildBotFlagged ? (
<Tooltip>
<TooltipTrigger asChild>
<span tabIndex={0} className="inline-flex shrink-0 cursor-help whitespace-nowrap text-xs font-medium text-amber-700 dark:text-amber-300">{t("accounts.botRisk")}</span>
</TooltipTrigger>
<TooltipContent>{t("accounts.botRiskTooltip")}</TooltipContent>
</Tooltip>
) : null}
</div>
<div className="flex min-h-4 w-fit min-w-0 items-center">
<Tooltip>
@@ -127,6 +119,19 @@ export function AccountNameCell({ account }: { account: AccountDTO }) {
</span>
</>
) : null}
{account.buildBotFlagged ? (
<>
<span className="mx-2 h-3 w-px shrink-0 bg-border" aria-hidden="true" />
<Tooltip>
<TooltipTrigger asChild>
<span tabIndex={0} aria-label={t("accounts.botRisk")} className="inline-flex cursor-help text-amber-500 focus-visible:outline-none dark:text-amber-400">
<Bot className="size-3.5" />
</span>
</TooltipTrigger>
<TooltipContent>{t("accounts.botRiskTooltip")}</TooltipContent>
</Tooltip>
</>
) : null}
</div>
</div>
);
@@ -162,10 +162,10 @@ export function RequestAuditsPage() {
{auditsQuery.isPending || (result && result.items.length > 0) ? (
<Table viewportRows={20} rowHeight={72} className="min-w-[1136px] table-fixed text-xs">
<colgroup>
<col className="w-40" />
<col className="w-36" />
<col className="w-44" />
<col className="w-20" />
<col className="w-20" />
<col className="w-24" />
<col className="w-76" />
<col className="w-20" />
<col className="w-20" />
+2 -2
View File
@@ -685,7 +685,7 @@ const resources = {
reasoning: "推理",
costUsd: "成本 ${{value}}",
sources: "来源 {{count}}",
serverTools: "调用服务端工具 {{count}} 次",
serverTools: "工具调用 {{count}} 次",
detailTitle: "请求诊断详情",
failedAttemptCount: "{{count}} 次失败",
attemptTimeline: "失败尝试",
@@ -1158,7 +1158,7 @@ const resources = {
reasoning: "Reasoning",
costUsd: "Cost ${{value}}",
sources: "Sources {{count}}",
serverTools: "Server tools called {{count}} times",
serverTools: "Tool calls {{count}} times",
detailTitle: "Request diagnostics",
failedAttemptCount: "{{count}} failed",
failedAttemptCount_one: "{{count}} failed attempt",