-
Notifications
You must be signed in to change notification settings - Fork 6.2k
feat: Add Anthropic Claude API integration with provider selection #1613
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: v2-dev
Are you sure you want to change the base?
feat: Add Anthropic Claude API integration with provider selection #1613
Conversation
Major Features: - Add Claude as an alternative AI provider alongside ChatGPT - Implement full Anthropic API client in Rust with extended context support - Support for 1M token context window via beta features - Provider selection UI in Settings Technical Implementation: - Created claude.rs module with HTTP client for Anthropic API - Added configuration fields for API key, provider selection, and extended context - Implemented Tauri commands for Claude message handling - Created custom claude-chat.html interface for Claude conversations - Updated message routing in Ask.tsx to support both providers - Modified webview setup to conditionally load ChatGPT or Claude interface Configuration: - Added anthropic_api_key, provider, and use_extended_context to AppConf - Enhanced Settings UI with provider selection and API key input - Implemented proper error handling and loading states Dependencies: - Added reqwest v0.12 for HTTP requests - Added base64 v0.22 for encoding support Files Changed: - src-tauri/src/core/claude.rs (new): Claude API client implementation - src-tauri/src/core/conf.rs: Extended configuration structure - src-tauri/src/core/cmd.rs: Added Claude-specific Tauri commands - src-tauri/src/core/setup.rs: Conditional webview loading based on provider - src/view/Settings.tsx: Complete Settings UI implementation - src/view/Ask.tsx: Provider-aware message routing - claude-chat.html (new): Claude chat interface
Daytona39264
left a comment
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.
commit
|
approved |
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.
Pull Request Overview
This PR adds support for Anthropic's Claude API as an alternative AI provider to ChatGPT. Users can now select between ChatGPT (web interface) and Claude (API) in the settings, with Claude requiring an API key configuration.
Key Changes:
- Added Claude API integration with configurable API key and extended context support
- Implemented a custom chat UI for Claude conversations in HTML/CSS/JS
- Created Settings page for provider selection and Claude API configuration
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| src/view/Settings.tsx | New settings UI component for provider selection and Claude API configuration |
| src/view/Ask.tsx | Extended chat input to support both ChatGPT and Claude providers with provider-specific message handling |
| src-tauri/src/main.rs | Registered new Tauri commands for provider management and Claude API integration |
| src-tauri/src/core/setup.rs | Modified webview initialization to conditionally load Claude chat UI or ChatGPT based on provider |
| src-tauri/src/core/mod.rs | Added claude module to core modules |
| src-tauri/src/core/conf.rs | Extended AppConf with provider, API key, and extended context configuration fields |
| src-tauri/src/core/cmd.rs | Added commands for provider settings, API key management, Claude messaging, and webview script evaluation |
| src-tauri/src/core/claude.rs | New module implementing Claude API client with message creation and response parsing |
| src-tauri/Cargo.toml | Added reqwest and base64 dependencies for HTTP requests and encoding |
| claude-chat.html | New standalone chat interface for Claude conversations with message display and theme support |
| Cargo.lock | Updated dependency lock file with new HTTP client and TLS-related crates |
Comments suppressed due to low confidence (1)
src/view/Ask.tsx:70
- Unused variable mainWebview.
const mainWebview = (window as any).__TAURI__?.webview;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Send to Claude API | ||
| const response = await invoke<string>('send_claude_message', { | ||
| messages: history, |
Copilot
AI
Nov 8, 2025
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 conversation history returned by getConversationHistory() is used directly without validation. If the history contains invalid role values or is malformed, the Claude API will reject the request. Consider adding validation to ensure all messages have valid roles ('user' or 'assistant') and proper structure before sending to the API.
| // Send to Claude API | |
| const response = await invoke<string>('send_claude_message', { | |
| messages: history, | |
| // Validate conversation history before sending to Claude API | |
| function isValidMessage(msg: any): msg is { role: string; content: string } { | |
| return ( | |
| msg && | |
| typeof msg === 'object' && | |
| (msg.role === 'user' || msg.role === 'assistant') && | |
| typeof msg.content === 'string' | |
| ); | |
| } | |
| const validHistory = Array.isArray(history) ? history.filter(isValidMessage) : []; | |
| if (validHistory.length !== history.length) { | |
| // Optionally, show an error or warning if some messages were invalid | |
| console.warn('Some invalid messages were removed from conversation history before sending to Claude API.'); | |
| } | |
| // Send to Claude API | |
| const response = await invoke<string>('send_claude_message', { | |
| messages: validHistory, |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
1 similar comment
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Improvements: - Increased max_tokens from 1024 to 8192 for better responses - Updated model identifier to claude-sonnet-4-5-20250514 - Added configurable DEFAULT_MAX_TOKENS constant - Created comprehensive CLAUDE_INTEGRATION.md documentation Documentation Includes: - Complete setup guide with step-by-step instructions - API configuration details and security information - Troubleshooting guide for common issues - Architecture diagrams and data flow explanations - API rate limits and usage guidelines - Future enhancement roadmap - Development and testing instructions Technical Improvements: - Better token limits for production use - Correct Claude model identifier - Enhanced code maintainability with constants
Added detailed implementation summary covering: - Executive summary and deliverables - Complete file changes documentation - Technical architecture and data flow - Security implementation details - UI/UX features - Testing and quality assurance - Deployment guide for users and developers - Known limitations and future enhancements - API rate limits and resources - Success metrics and lessons learned This document serves as a complete reference for the Anthropic Claude API integration project.
Final project deliverable documenting: - Complete executive summary - All deliverables and features - Technical architecture and implementation - Security and testing details - Deployment instructions - Next steps for merge completion - Comprehensive documentation index - Success metrics and completion checklist This report serves as the definitive completion document for the Anthropic Claude API integration.
Final task status document confirming: - All code implementation complete - All documentation complete - All commits pushed to remote - Branch synced and clean - Ready for production deployment This concludes the Anthropic Claude API integration task.
Major Features:
Technical Implementation:
Configuration:
Dependencies:
Files Changed: