From 4efa8a1282cc22e266bc3db2bc7d63d78d5ed381 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Fri, 24 Oct 2025 17:00:21 +0200 Subject: [PATCH] Updates Anthropic API limits with detailed documentation Revises token and character limit constants with more precise descriptions - Increases default max output tokens from 4000 to 8192 - Expands documentation explaining token-to-character estimation - Provides context about current Claude model token limits - Clarifies variability in character-to-token conversions --- settings.ts | 2 +- types.ts | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/settings.ts b/settings.ts index 3710bd4..51de3b8 100644 --- a/settings.ts +++ b/settings.ts @@ -235,7 +235,7 @@ export class FreewritingCleanupSettingTab extends PluginSettingTab { const limits = usageDiv.createEl('p'); limits.createEl('strong', { text: 'Limits: ' }); - limits.appendText(`Maximum ${ANTHROPIC_LIMITS.MAX_CHARACTERS.toLocaleString()} characters per cleanup (~${Math.floor(ANTHROPIC_LIMITS.MAX_TOKENS / 4).toLocaleString()} words estimated)`); + limits.appendText(`Maximum ${ANTHROPIC_LIMITS.MAX_TOKENS.toLocaleString()} tokens per cleanup (~${ANTHROPIC_LIMITS.MAX_CHARACTERS.toLocaleString()} characters, varies by language)`); const format = usageDiv.createEl('p'); format.createEl('strong', { text: 'Format: ' }); diff --git a/types.ts b/types.ts index 746bc59..58d3f33 100644 --- a/types.ts +++ b/types.ts @@ -231,10 +231,24 @@ export const COMMENTARY_PRESETS: Record, stri * Used for validation before making API calls. */ export const ANTHROPIC_LIMITS = { - /** Maximum input tokens */ + /** Maximum input tokens allowed by Claude API */ MAX_TOKENS: 200000, - /** Maximum input characters */ - MAX_CHARACTERS: 680000, - /** Default maximum output tokens per request */ - DEFAULT_MAX_OUTPUT_TOKENS: 4000 + /** + * Approximate maximum input characters + * + * Character count is approximate and depends on tokenization. + * Uses rough estimate of ≈ 4 characters per token, which varies by language + * and text structure. Actual token count may differ from this estimation. + */ + MAX_CHARACTERS: 800000, // Derived from MAX_TOKENS * 4 (conservative estimate) + /** + * Default maximum output tokens per request + * + * Set to 8192 which works for most current Claude models: + * - Claude 3 Haiku: 4096 tokens (will be capped by API) + * - Claude 3.5 Sonnet: 8192 tokens + * - Claude 3.5 Haiku: 8192 tokens + * - Future models may support higher limits + */ + DEFAULT_MAX_OUTPUT_TOKENS: 8192 } as const; \ No newline at end of file