Add Anthropic API integration, remove locale settings UI
All checks were successful
Build and Push Docker Image / build (push) Successful in 13m15s
All checks were successful
Build and Push Docker Image / build (push) Successful in 13m15s
Anthropic API: - Add @anthropic-ai/sdk with adapter wrapping OpenAI-shaped interface - Support Claude models (opus, sonnet, haiku) with extended thinking - Auto-reset model on provider switch, JSON retry logic - Add Claude model pricing to ai-usage tracker - Update AI settings form with Anthropic provider option - Add provider field to AIUsageLog for cross-provider cost tracking Locale Settings Removal: - Strip Localization tab from admin settings (mobile + desktop) - Remove i18n settings from router and feature flags - Remove LOCALIZATION from SettingCategory enum - Keep franc document language detection intact Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,7 @@ export interface LogAIUsageInput {
|
||||
entityType?: string
|
||||
entityId?: string
|
||||
model: string
|
||||
provider?: string
|
||||
promptTokens: number
|
||||
completionTokens: number
|
||||
totalTokens: number
|
||||
@@ -98,6 +99,13 @@ const MODEL_PRICING: Record<string, ModelPricing> = {
|
||||
|
||||
// o4 reasoning models (future-proofing)
|
||||
'o4-mini': { input: 1.1, output: 4.4 },
|
||||
|
||||
// Anthropic Claude models
|
||||
'claude-opus-4-5-20250514': { input: 15.0, output: 75.0 },
|
||||
'claude-sonnet-4-5-20250514': { input: 3.0, output: 15.0 },
|
||||
'claude-haiku-3-5-20241022': { input: 0.8, output: 4.0 },
|
||||
'claude-opus-4-20250514': { input: 15.0, output: 75.0 },
|
||||
'claude-sonnet-4-20250514': { input: 3.0, output: 15.0 },
|
||||
}
|
||||
|
||||
// Default pricing for unknown models (conservative estimate)
|
||||
@@ -150,6 +158,16 @@ function getModelPricing(model: string): ModelPricing {
|
||||
if (modelLower.startsWith('o4')) {
|
||||
return MODEL_PRICING['o4-mini'] || DEFAULT_PRICING
|
||||
}
|
||||
// Anthropic Claude prefix fallbacks
|
||||
if (modelLower.startsWith('claude-opus')) {
|
||||
return { input: 15.0, output: 75.0 }
|
||||
}
|
||||
if (modelLower.startsWith('claude-sonnet')) {
|
||||
return { input: 3.0, output: 15.0 }
|
||||
}
|
||||
if (modelLower.startsWith('claude-haiku')) {
|
||||
return { input: 0.8, output: 4.0 }
|
||||
}
|
||||
|
||||
return DEFAULT_PRICING
|
||||
}
|
||||
@@ -200,6 +218,7 @@ export async function logAIUsage(input: LogAIUsageInput): Promise<void> {
|
||||
entityType: input.entityType,
|
||||
entityId: input.entityId,
|
||||
model: input.model,
|
||||
provider: input.provider,
|
||||
promptTokens: input.promptTokens,
|
||||
completionTokens: input.completionTokens,
|
||||
totalTokens: input.totalTokens,
|
||||
|
||||
Reference in New Issue
Block a user