Skip to content

Add DeepSeek AI as a new search engine option with API key management #146

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 6, 2025

🚀 New Feature: DeepSeek AI Integration

This PR adds DeepSeek AI as a new search engine option to Codelf, providing AI-powered code suggestions and variable naming alongside the existing SearchCode.com functionality.

✨ Features Added

🔍 Dual Search Engine Support

  • SearchCode: Real-world code from GitHub, GitLab, BitBucket (existing, default)
  • DeepSeek AI: AI-powered variable naming and code suggestions (new)

🔑 Flexible API Key Management

  • Optional API key configuration via settings modal
  • Secure browser-only storage (localStorage) - never sent to Codelf servers
  • Fallback to demo mode with mock results when no API key provided
  • Clear privacy notices and user control

🎨 Seamless UI Integration

  • New search engine selector dropdown in main interface
  • Settings button for DeepSeek configuration when selected
  • Maintains consistent design with existing components
  • Responsive design support

🛠 Implementation Details

New Components

  • DeepSeekSearchData: Service class for API integration with caching and error handling
  • SearchEngineSelector: React component for engine selection with settings modal

Enhanced Components

  • SearchCodeModel: Updated to route requests between different search engines
  • SearchBar: Integrated search engine selector
  • MainContainer: Added search engine change handling

📊 Usage Example

// Users can now select DeepSeek AI from the dropdown
// and optionally configure their API key for enhanced results

// Example search flow:
1. Select "DeepSeek AI" from search engine dropdown
2. Optionally click settings ⚙️ to configure API key
3. Search for "user authentication" 
4. Get AI-generated variable names and patterns

🔧 API Integration

  • Endpoint: https://api.deepseek.com/chat/completions
  • Authentication: Bearer token (user's API key)
  • Fallback: Demo mode with mock results when no API key
  • Caching: Session-based result caching for performance
  • Error Handling: Graceful fallback on API failures

🔒 Privacy & Security

  • API keys stored only in user's browser (localStorage)
  • Never transmitted to Codelf servers
  • User can clear API key anytime
  • Transparent about data usage
  • No cross-engine data sharing

📱 User Interface

Search Engine: [DeepSeek AI ▼] [⚙️ Settings]
┌─────────────────────────────────┐
│ Search Input Field              │
│ [🔍] [Language Filter ▼]       │
└─────────────────────────────────┘

Settings Modal:

🧠 DeepSeek AI Settings
┌─────────────────────────────────┐
│ API Key (Optional)              │
│ [••••••••••••••••••••] [👁️]    │
│                                 │
│ ℹ️ Privacy Notice: API key is   │
│   stored locally in browser     │
│                                 │
│ [Clear Key] [Cancel] [Save]     │
└─────────────────────────────────┘

🧪 Testing

  • ✅ API key storage/retrieval functionality
  • ✅ Search result parsing and display
  • ✅ Error handling and fallback scenarios
  • ✅ UI component rendering and interactions
  • ✅ Backward compatibility with existing SearchCode functionality

📈 Impact

  • No Breaking Changes: Full backward compatibility maintained
  • Zero New Dependencies: Uses existing React/Semantic UI components
  • Minimal Code Changes: 611 lines added, 11 removed across 7 files
  • Enhanced User Experience: More search options and AI-powered suggestions

🌟 Benefits

  1. More Options: Users can choose between real-world code examples and AI suggestions
  2. Flexibility: Works with or without API key
  3. Privacy-First: User controls all data and API key storage
  4. Performance: Built-in caching and error handling
  5. Extensible: Easy to add more AI providers in the future

This enhancement maintains Codelf's core mission of helping developers find better variable names while adding the power of modern AI assistance.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] 集成 deepseek 作为新的搜索引擎并支持 API key 设置(可选) Add DeepSeek AI as a new search engine option with API key management Jun 6, 2025
@Copilot Copilot AI requested a review from unbug June 6, 2025 03:01
Copilot finished work on behalf of unbug June 6, 2025 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants