mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-23 08:25:57 +00:00
fix: use backend thread token usage for header total (#2800)
* fix: use backend thread token usage for header total * Refactor thread token usage fetch
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import type { TokenUsage } from "@/core/messages/usage";
|
||||
|
||||
import type { ThreadTokenUsageResponse } from "./types";
|
||||
|
||||
export function threadTokenUsageQueryKey(threadId?: string | null) {
|
||||
return ["thread-token-usage", threadId] as const;
|
||||
}
|
||||
|
||||
export function threadTokenUsageToTokenUsage(
|
||||
usage: ThreadTokenUsageResponse | null | undefined,
|
||||
): TokenUsage | null {
|
||||
if (!usage) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
inputTokens: usage.total_input_tokens ?? 0,
|
||||
outputTokens: usage.total_output_tokens ?? 0,
|
||||
totalTokens: usage.total_tokens ?? 0,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user