Skip to content

Conversation

@thornboo
Copy link

@thornboo thornboo commented Feb 3, 2026

本次改动概览

  • 新增 AI 配置字段 apiType,用于选择协议格式(OpenAI / Claude / Gemini)。
  • 统一 AI 分析、AI 搜索与连接测试的请求通道,根据 apiType 走对应的请求路径与鉴权方式。
  • 优化 baseUrl 拼接逻辑,兼容用户将 baseUrl 填到版本前缀(如 .../v1 或 .../v1beta),避免重复拼接版本段。
  • 连接测试改为发起最小可用请求并设置超时,更能真实验证“key + model + endpoint”可用性。

影响范围

  • 仅涉及 AI 配置与 AI 服务调用链,不影响仓库列表/筛选等其它业务逻辑。

改动文件

  • src/types/index.ts:AIConfig 增加 apiType?: 'openai' | 'claude' | 'gemini'
  • src/components/SettingsPanel.tsx:新增 API Format 选择与提示文案
  • src/services/aiService.ts:按协议适配 analyze/search/testConnection 的请求实现

Summary by CodeRabbit

  • New Features
    • Added multi-provider AI support: select between OpenAI, Claude, or Gemini in the AI configuration settings.
    • API Format dropdown now appears in the AI configuration form.
    • Base URL placeholder adapts based on the selected AI provider for clearer guidance.
    • API format is now displayed in the AI configurations list for easy identification.

@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

The changes introduce multi-provider AI API support, enabling users to select between OpenAI, Claude, and Gemini through the settings panel. The service layer implements provider-agnostic request handling with unified dispatcher logic and provider-specific response parsing. The type system adds an apiType field to AIConfig.

Changes

Cohort / File(s) Summary
Type System
src/types/index.ts
Added optional apiType field to AIConfig interface with values 'openai' | 'claude' | 'gemini' to support multi-provider configuration.
UI Configuration
src/components/SettingsPanel.tsx
Added API type dropdown selector in AI configuration form; updated Base URL placeholder text to adapt based on selected provider; displays API format in configurations list and config summary line.
Service Implementation
src/services/aiService.ts
Implemented provider-agnostic request dispatcher (requestText()) handling OpenAI, Claude, and Gemini with provider-specific request/response parsing, content extraction, URL normalization, and error handling. Updated analyzeRepository(), testConnection(), and search flows to use unified dispatcher while maintaining existing public signatures.

Sequence Diagram

sequenceDiagram
    actor User
    participant SettingsPanel
    participant AIService
    participant OpenAI/Claude/Gemini

    User->>SettingsPanel: Select API type (openai/claude/gemini)
    SettingsPanel->>SettingsPanel: Save apiType to AIConfig
    
    User->>SettingsPanel: Trigger AI operation (analyze/search)
    SettingsPanel->>AIService: Request with AIConfig (includes apiType)
    
    AIService->>AIService: requestText(): Determine provider<br/>via getApiType() selector
    AIService->>AIService: buildApiUrl(): Normalize URL<br/>based on selected provider
    
    alt apiType = 'openai'
        AIService->>OpenAI/Claude/Gemini: POST /chat/completions
    else apiType = 'claude'
        AIService->>OpenAI/Claude/Gemini: POST /messages
    else apiType = 'gemini'
        AIService->>OpenAI/Claude/Gemini: POST /v1beta/generateContent
    end
    
    OpenAI/Claude/Gemini-->>AIService: Provider-specific response
    AIService->>AIService: Extract content:<br/>parse JSON/text blocks<br/>based on provider format
    AIService-->>SettingsPanel: Parsed AI response
    SettingsPanel->>User: Display results
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Poem

🐰 Three rabbits, one AI door,
OpenAI, Claude, and more!
Service hops through provider lanes,
UI dropdowns break the chains,
Config types now unified, hooray! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding support for multiple AI API formats and fixing connection testing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant