-
-
Notifications
You must be signed in to change notification settings - Fork 217
feat(usage): add anthropic effort tracking and display. #900 #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,8 @@ | |||||
| "next": "次へ", | ||||||
| "noLogs": "ログがありません", | ||||||
| "unknownModel": "不明なモデル", | ||||||
| "billingModel": "課金: {model}" | ||||||
| "billingModel": "課金: {model}", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The This same issue applies to:
Prompt To Fix With AIThis is a comment left during a code review.
Path: messages/ja/myUsage.json
Line: 61
Comment:
**`anthropicEffort` label not translated**
The `billingModel` label is properly translated in all non-English locales (e.g. `"課金: {model}"` in Japanese, `"Биллинг: {model}"` in Russian, `"计费:{model}"` in Chinese), but `anthropicEffort` is left as `"Effort: {effort}"` across all non-English locales. For consistency, this label should be translated.
This same issue applies to:
- `messages/ja/myUsage.json:61` — `"Effort: {effort}"` (should be e.g. `"エフォート: {effort}"`)
- `messages/ru/myUsage.json:61` — `"Effort: {effort}"` (should be e.g. `"Уровень сложности: {effort}"`)
- `messages/zh-CN/myUsage.json:61` — `"Effort: {effort}"` (should be e.g. `"思考强度: {effort}"`)
- `messages/zh-TW/myUsage.json:61` — `"Effort: {effort}"` (should be e.g. `"思考強度: {effort}"`)
- `messages/ja/dashboard.json` — same pattern
- `messages/ru/dashboard.json` — same pattern
- `messages/zh-CN/dashboard.json` — same pattern
- `messages/zh-TW/dashboard.json` — same pattern
How can I resolve this? If you propose a fix, please make it concise. |
||||||
| "anthropicEffort": "Effort: {effort}" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new i18n key
Suggested change
|
||||||
| }, | ||||||
| "expiration": { | ||||||
| "title": "有効期限", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -158,6 +158,7 @@ | |||||
| "nonBilling": "Не тарифицируется", | ||||||
| "skipped": "Пропущено", | ||||||
| "specialSettings": "Особые", | ||||||
| "anthropicEffort": "Effort: {effort}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new i18n key
Suggested change
|
||||||
| "times": "раз", | ||||||
| "loadedCount": "Загружено {count} записей", | ||||||
| "loadingMore": "Загрузка...", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,8 @@ | |||||
| "next": "Вперед", | ||||||
| "noLogs": "Нет записей", | ||||||
| "unknownModel": "Неизвестная модель", | ||||||
| "billingModel": "Биллинг: {model}" | ||||||
| "billingModel": "Биллинг: {model}", | ||||||
| "anthropicEffort": "Effort: {effort}" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new i18n key
Suggested change
|
||||||
| }, | ||||||
| "expiration": { | ||||||
| "title": "Срок действия", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -158,6 +158,7 @@ | |||||
| "nonBilling": "非计费", | ||||||
| "skipped": "已跳过", | ||||||
| "specialSettings": "特殊设置", | ||||||
| "anthropicEffort": "Effort: {effort}", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. zh-CN 文案不要直接回退成英文。 这里会直接显示在中文界面里, As per coding guidelines "All user-facing strings must use i18n (5 languages supported: zh-CN, zh-TW, en, ja, ru). Never hardcode display text". 🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new i18n key
Suggested change
|
||||||
| "times": "次", | ||||||
| "loadedCount": "已加载 {count} 条记录", | ||||||
| "loadingMore": "加载更多中...", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,8 @@ | |||||
| "next": "下一页", | ||||||
| "noLogs": "暂无日志", | ||||||
| "unknownModel": "未知模型", | ||||||
| "billingModel": "计费:{model}" | ||||||
| "billingModel": "计费:{model}", | ||||||
| "anthropicEffort": "Effort: {effort}" | ||||||
|
Comment on lines
+61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里还没有真正完成本地化。
🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new i18n key
Suggested change
|
||||||
| }, | ||||||
| "expiration": { | ||||||
| "title": "过期时间", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -158,6 +158,7 @@ | |||||
| "nonBilling": "非計費", | ||||||
| "skipped": "已跳過", | ||||||
| "specialSettings": "特殊設定", | ||||||
| "anthropicEffort": "Effort: {effort}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new i18n key
Suggested change
|
||||||
| "times": "次數", | ||||||
| "loadedCount": "已載入 {count} 筆記錄", | ||||||
| "loadingMore": "載入更多中...", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,7 +58,8 @@ | |||||
| "next": "下一頁", | ||||||
| "noLogs": "暫無日誌", | ||||||
| "unknownModel": "未知的模型", | ||||||
| "billingModel": "計費:{model}" | ||||||
| "billingModel": "計費:{model}", | ||||||
| "anthropicEffort": "Effort: {effort}" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new i18n key
Suggested change
|
||||||
| }, | ||||||
| "expiration": { | ||||||
| "title": "到期時間", | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { Badge } from "@/components/ui/badge"; | ||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| const ANTHROPIC_EFFORT_BADGE_STYLES: Record<string, string> = { | ||
| auto: "border-sky-300 bg-gradient-to-r from-cyan-50 via-sky-50 to-indigo-50 text-sky-800 dark:border-sky-700 dark:from-cyan-950/40 dark:via-sky-950/40 dark:to-indigo-950/40 dark:text-sky-200", | ||
| low: "border-slate-200 bg-slate-50 text-slate-700 dark:border-slate-700 dark:bg-slate-900/40 dark:text-slate-300", | ||
| medium: | ||
| "border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300", | ||
| high: "border-rose-200 bg-rose-50 text-rose-700 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-300", | ||
| max: "border-red-300 bg-red-100 text-red-800 dark:border-red-700 dark:bg-red-950/40 dark:text-red-200", | ||
| }; | ||
|
|
||
| const DEFAULT_BADGE_STYLE = | ||
| "border-muted-foreground/20 bg-muted/40 text-muted-foreground dark:border-muted-foreground/30 dark:bg-muted/20"; | ||
|
|
||
| export function getAnthropicEffortBadgeClassName(effort: string): string { | ||
| return ANTHROPIC_EFFORT_BADGE_STYLES[effort.trim().toLowerCase()] ?? DEFAULT_BADGE_STYLE; | ||
| } | ||
|
|
||
| interface AnthropicEffortBadgeProps { | ||
| effort: string; | ||
| label: string; | ||
| className?: string; | ||
| } | ||
|
|
||
| export function AnthropicEffortBadge({ effort, label, className }: AnthropicEffortBadgeProps) { | ||
| return ( | ||
| <Badge | ||
| variant="outline" | ||
| className={cn( | ||
| "w-fit px-1 text-[10px] leading-tight whitespace-nowrap", | ||
| getAnthropicEffortBadgeClassName(effort), | ||
| className | ||
| )} | ||
| > | ||
| {label} | ||
| </Badge> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import type { SpecialSetting } from "@/types/special-settings"; | ||
|
|
||
| function normalizeAnthropicEffort(value: unknown): string | null { | ||
| if (typeof value !== "string") { | ||
| return null; | ||
| } | ||
|
|
||
| const trimmed = value.trim(); | ||
| return trimmed.length > 0 ? trimmed : null; | ||
| } | ||
|
|
||
| export function extractAnthropicEffortFromRequestBody(requestBody: unknown): string | null { | ||
| if (!requestBody || typeof requestBody !== "object" || Array.isArray(requestBody)) { | ||
| return null; | ||
| } | ||
|
|
||
| const outputConfig = (requestBody as Record<string, unknown>).output_config; | ||
| if (!outputConfig || typeof outputConfig !== "object" || Array.isArray(outputConfig)) { | ||
| return null; | ||
| } | ||
|
|
||
| return normalizeAnthropicEffort((outputConfig as Record<string, unknown>).effort); | ||
| } | ||
|
|
||
| export function extractAnthropicEffortFromSpecialSettings( | ||
| specialSettings: SpecialSetting[] | null | undefined | ||
| ): string | null { | ||
| if (!Array.isArray(specialSettings)) { | ||
| return null; | ||
| } | ||
|
|
||
| for (const setting of specialSettings) { | ||
| if (setting.type !== "anthropic_effort") { | ||
| continue; | ||
| } | ||
|
|
||
| const normalized = normalizeAnthropicEffort(setting.effort); | ||
| if (normalized) { | ||
| return normalized; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new i18n key
anthropicEfforthas been added, but its value is untranslated. For consistency with other translated keys likebillingModel, please provide a Japanese translation for "Effort: {effort}". A common translation would beエフォート: {effort}.