Commit Graph
5 Commits
Author SHA1 Message Date
AlexKucera 3d1227dc45 Improves model fallback and caching strategy
Adds API key validation before fetching models
Ensures consistent fallback model caching on API errors or missing key
Reduces redundant code by centralizing fallback model caching logic

Relates to dynamic-models branch
2025-10-24 11:03:30 +02:00
AlexKucera fcc495aa8f Enhances model service fallback and caching logic
Improves model retrieval strategy for scenarios with invalid/missing API keys

Adds immediate fallback model generation when API key is invalid
Ensures consistent model caching for both API and fallback scenarios
Sorts model options alphabetically for improved user experience

Introduces new getFallbackOptions() method for direct fallback access
Refactors model refresh and error handling to provide more robust model selection
2025-10-24 11:00:42 +02:00
AlexKucera 4db5639160 Adds token usage tracking for text cleanup requests
Enhances Anthropic API client to return token usage information

Modifies cleanup service to capture and store input and output token counts from API responses
Refactors request and response handling to extract and pass usage metrics
Provides more detailed tracking of API request resource consumption
2025-10-24 10:55:54 +02:00
Jarvis 7b23ed6615 feat: add dynamic model fetching from Anthropic API
Replace hardcoded model list with dynamic API-based model fetching
that queries the Anthropic models endpoint. Implements 24-hour caching
with automatic fallback to hardcoded models if API is unavailable.

Changes:
- Add ModelService to fetch and cache available models from API
- Implement 24-hour TTL cache persisted in plugin data
- Update AnthropicClient with fetchModels() method
- Modify settings UI to load models asynchronously with loading states
- Auto-refresh models when API key is entered or changed
- Display model names using display_name field from API
- Preserve user's selected model across updates and restarts
- Show notice when falling back to hardcoded model list
- Change model type from strict enum to string for dynamic support

Technical details:
- New ModelInfo and ModelsListResponse interfaces for API response
- ModelCache interface with timestamp for TTL validation
- FreewritingCleanupData extends settings to include cache
- Settings dropdown disabled during model fetch/refresh
- Fallback to ANTHROPIC_MODELS constant on API failure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 10:25:22 +02:00
AlexKucera a63d184448 Implements freewriting cleanup plugin
Adds a plugin to clean up freewriting text using the Anthropic API.

This initial commit introduces core functionality, including:
- API client for interacting with Anthropic's Claude models.
- Service for orchestrating cleanup operations and managing API calls.
- Command for executing the cleanup process on selected text within Obsidian editor.
- Settings tab for configuring the API key, model, prompts, and commentary preferences.
- Type definitions for settings, API requests/responses, and cleanup results.

The plugin provides a command to clean up selected text, apply custom prompts, and optionally generate commentary on the freewriting session.
2025-09-20 12:14:55 +02:00