mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-20 11:01:59 +00:00
模型不在价格目录里时运行金额写「金额无法估算」,不写 $0:真实运行里 token 记到了上百万,金额却是 $0,看着像没花钱。llm.end 发出时,用了 token、模型却不在价格目录里的标 unpriced(目录里标 0 价的本地模型不算);运行用量按 llm.end 数出 unpriced_calls,成功的运行也补上(状态里的用量分不出 0 是免费还是没价)。运行详情、画布运行面板、航迹的金额:一分都没估出来写「金额无法估算」,估出一部分写「≥ $x」,悬停说几次调用不在价格目录中。check-trace 补断言;流式用量测试和注释里的真实调用次数换成概括说法
This commit is contained in:
@@ -8,7 +8,7 @@ import { confirmDialog, Kbd, Spinner, StatusBadge, toast } from '../components/u
|
||||
import { formatCost, formatDuration, formatLapse, formatOffset, formatSpan, formatTokens, NONE } from '../lib/format'
|
||||
import { isTypingTarget, matchShortcut } from '../lib/keys'
|
||||
import { statusMeta, STATUS, type StatusCode } from '../lib/status'
|
||||
import { issuanceLabel, runClassLabel } from '../lib/terms'
|
||||
import { COST_TEXT, issuanceLabel, runClassLabel, runCostText } from '../lib/terms'
|
||||
import { lastStampOf, projectSettled, useDock, waitedMs } from '../canvas/RunTimeline'
|
||||
import { structureSig, useStudio } from '../store/studio'
|
||||
import type { RunEvent } from '../types'
|
||||
@@ -91,6 +91,8 @@ export interface RunGlance {
|
||||
series: [number, number][]
|
||||
tokens: number | null
|
||||
cost: number | null
|
||||
/** 金额估不出来的调用次数(模型不在价格目录中);有的话金额不写 $0 */
|
||||
unpriced: number
|
||||
/** 这一段执行还剩多少时间;null = 不知道上限或眼下不在计时 */
|
||||
remainingMs: number | null
|
||||
limitMs: number | null
|
||||
@@ -220,6 +222,7 @@ export function useRunGlance(active: boolean): RunGlance {
|
||||
const replayTok = proj.tokensIn != null && proj.tokensOut != null ? proj.tokensIn + proj.tokensOut : null
|
||||
const tokens = replayAt != null ? replayTok : backendTok ?? (seen ? usage.tokensIn + usage.tokensOut : null)
|
||||
const cost = replayAt != null ? proj.costUsd ?? null : backendCost ?? (seen ? usage.costUsd : null)
|
||||
const unpriced = (settledUsage ? num(runUsage.unpriced_calls) : null) ?? trace.unpricedCalls
|
||||
|
||||
// 时限按"这一段执行"计:等人工审批时执行已经结束,那段不算(和后端一致)
|
||||
const drive = trace.drives[trace.drives.length - 1]
|
||||
@@ -253,7 +256,7 @@ export function useRunGlance(active: boolean): RunGlance {
|
||||
headline: headlineOf(trace, phase, states, at, label, runError, replayAt == null ? cancelled : ''),
|
||||
executing: phase === 'running' && cells.some((c) => c.state === 'running' && !trace.nodes[c.id]?.looping),
|
||||
cells, done, visited, parallelNow: proj.parallelNow, series: trace.parallelSeries,
|
||||
tokens, cost, remainingMs, limitMs, attention,
|
||||
tokens, cost, unpriced, remainingMs, limitMs, attention,
|
||||
failedNodeId: trace.failedNodeId, waitingNodeId: trace.waitingNodeId,
|
||||
}
|
||||
}
|
||||
@@ -591,7 +594,7 @@ export function RunCapsule() {
|
||||
<span className="sf-cap-nodes tnum hidden lg:inline" title="完成的节点 / 全部节点">{nodesText}</span>
|
||||
<span className="sf-cap-sep hidden xl:block" />
|
||||
<span className="sf-cap-usage tnum hidden xl:inline">
|
||||
{tokens}{g.cost ? ` · ${formatCost(g.cost)}` : ''}
|
||||
{tokens}{g.cost || g.unpriced ? ` · ${runCostText(g.cost, g.unpriced)}` : ''}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
@@ -654,7 +657,9 @@ export function RunCapsule() {
|
||||
<div className="sf-metric">
|
||||
<div className="sf-metric-k">用量</div>
|
||||
<div className="sf-metric-v tnum">{tokens}</div>
|
||||
<div className="sf-metric-s tnum">{g.cost != null ? `≈ ${formatCost(g.cost)}` : NONE}</div>
|
||||
<div className="sf-metric-s tnum" title={g.unpriced ? COST_TEXT.unpricedTitle(g.unpriced) : undefined}>
|
||||
{g.unpriced ? runCostText(g.cost, g.unpriced) : g.cost != null ? `≈ ${formatCost(g.cost)}` : NONE}
|
||||
</div>
|
||||
</div>
|
||||
<div className="sf-metric">
|
||||
<div className="sf-metric-k">时限</div>
|
||||
|
||||
@@ -96,6 +96,8 @@ export interface Trace {
|
||||
tokensIn: number
|
||||
tokensOut: number
|
||||
costUsd: number
|
||||
/** 金额估不出来的调用次数(llm.end 标了 unpriced:模型不在价格目录中)。这时 costUsd 的 0 不是「没花钱」 */
|
||||
unpricedCalls: number
|
||||
failedNodeId?: string
|
||||
waitingNodeId?: string
|
||||
issuance?: {
|
||||
@@ -238,7 +240,7 @@ export const lastEventAt = (t: Trace): number => t.book.clock
|
||||
|
||||
export function emptyTrace(): Trace {
|
||||
return {
|
||||
phase: 'idle', waitMs: 0, nodes: {}, tokensIn: 0, tokensOut: 0, costUsd: 0,
|
||||
phase: 'idle', waitMs: 0, nodes: {}, tokensIn: 0, tokensOut: 0, costUsd: 0, unpricedCalls: 0,
|
||||
lastSeq: 0, parallelSeries: [], usageSeries: [], timed: true, drives: [], waits: [], phases: [],
|
||||
lastReplay: false,
|
||||
book: { clock: 0, awaiting: false, dispatchFrom: {}, exactDispatch: {}, asking: {} },
|
||||
@@ -673,6 +675,7 @@ export function foldEvent(t: Trace, ev: RunEvent): Trace {
|
||||
next.tokensIn += inTok
|
||||
next.tokensOut += outTok
|
||||
next.costUsd += cost
|
||||
if (d.unpriced === true) next.unpricedCalls += 1
|
||||
next.usageSeries = [...next.usageSeries, [at, next.tokensIn, next.tokensOut, next.costUsd]]
|
||||
if (nodeId) {
|
||||
const n = node(nodeId)
|
||||
@@ -816,6 +819,7 @@ export function foldEvent(t: Trace, ev: RunEvent): Trace {
|
||||
next.tokensIn = num(u.input_tokens) ?? next.tokensIn
|
||||
next.tokensOut = num(u.output_tokens) ?? next.tokensOut
|
||||
next.costUsd = num(u.cost_usd) ?? next.costUsd
|
||||
next.unpricedCalls = num(u.unpriced_calls) ?? next.unpricedCalls
|
||||
}
|
||||
const timing = d.timing
|
||||
if (timing && num(timing.wall_ms) != null) {
|
||||
|
||||
Reference in New Issue
Block a user