feat: Settings page, DELETE traces endpoint, Anthropic SDK, dashboard bug fixes
- Add /dashboard/settings with SDK connection details, data stats, purge - Add DELETE /api/traces/[id] with cascade deletion - Add Anthropic integration (wrap_anthropic) for Python SDK - Fix missing root duration (totalDuration -> durationMs mapping) - Fix truncated JSON in decision tree nodes (extract readable labels) - Fix hardcoded 128K maxTokens in token gauge (model-aware context windows) - Enable Settings nav item in sidebar
This commit is contained in:
@@ -461,13 +461,35 @@ function CostBreakdown({
|
||||
// Section C: Token Usage Gauge
|
||||
function TokenUsageGauge({ trace }: { trace: Trace }) {
|
||||
const tokenData = useMemo(() => {
|
||||
// Try to get total tokens from various sources
|
||||
const totalTokens =
|
||||
(trace.metadata?.totalTokens as number | null | undefined) ??
|
||||
(trace.metadata?.tokenCount as number | null | undefined) ??
|
||||
null;
|
||||
|
||||
const maxTokens = 128000; // Default context window
|
||||
const modelContextWindows: Record<string, number> = {
|
||||
"gpt-4": 8192,
|
||||
"gpt-4-32k": 32768,
|
||||
"gpt-4-turbo": 128000,
|
||||
"gpt-4o": 128000,
|
||||
"gpt-4o-mini": 128000,
|
||||
"gpt-3.5-turbo": 16385,
|
||||
"claude-3-opus": 200000,
|
||||
"claude-3-sonnet": 200000,
|
||||
"claude-3-haiku": 200000,
|
||||
"claude-3.5-sonnet": 200000,
|
||||
"claude-4-opus": 200000,
|
||||
"claude-4-sonnet": 200000,
|
||||
};
|
||||
|
||||
const model = (trace.metadata?.model as string | undefined) ?? "";
|
||||
const modelLower = model.toLowerCase();
|
||||
let maxTokens = 128000;
|
||||
for (const [prefix, ctx] of Object.entries(modelContextWindows)) {
|
||||
if (modelLower.startsWith(prefix)) {
|
||||
maxTokens = ctx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
totalTokens,
|
||||
|
||||
Reference in New Issue
Block a user