-
Notifications
You must be signed in to change notification settings - Fork 614
feat: update Doubao provider with new models #816
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
Conversation
WalkthroughThe change updates Doubao-related model configurations: populates providerModelSettings with DeepSeek and Doubao Seed variants and revises doubaoProvider’s model list to include DeepSeek entries (with flags) and six new Doubao Seed models. No API signatures, logic, or control flow changed. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/presenter/configPresenter/providerModelSettings.ts (1)
2791-2806: Make model-id matching deterministic (avoid substring collisions).Using includes() can select the wrong config (e.g., 'deepseek-v3' matches 'deepseek-v3-1-250821'). Prefer “longest prefix” matching.
- // 遍历该提供商的模型数组,查找匹配的模型配置 - for (const config of providerSetting.models) { - // 检查是否有任何匹配条件符合 - if (config.match.some((matchStr) => lowerModelId.includes(matchStr.toLowerCase()))) { - return { - maxTokens: config.maxTokens, - contextLength: config.contextLength, - temperature: config.temperature, // 保持可选,某些模型不支持 - vision: config.vision || false, - functionCall: config.functionCall || false, - reasoning: config.reasoning || false, - type: config.type || ModelType.Chat, - reasoningEffort: config.reasoningEffort, - verbosity: config.verbosity, - maxCompletionTokens: config.maxCompletionTokens - } - } - } + // Prefer the most specific (longest) prefix match to avoid collisions + let best: ProviderModelSetting | undefined + let bestLen = -1 + for (const config of providerSetting.models) { + for (const matchStr of config.match) { + const m = matchStr.toLowerCase() + if (lowerModelId === m || lowerModelId.startsWith(m)) { + if (m.length > bestLen) { + best = config + bestLen = m.length + } + } + } + } + if (best) { + return { + maxTokens: best.maxTokens, + contextLength: best.contextLength, + temperature: best.temperature, + vision: best.vision || false, + functionCall: best.functionCall || false, + reasoning: best.reasoning || false, + type: best.type || ModelType.Chat, + reasoningEffort: best.reasoningEffort, + verbosity: best.verbosity, + maxCompletionTokens: best.maxCompletionTokens + } + }src/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts (1)
155-162: Add try-catch with structured logging; don’t swallow errors.Main-process TS must handle errors with meaningful, structured logs and rethrow.
async completions( messages: ChatMessage[], modelId: string, temperature?: number, maxTokens?: number ): Promise<LLMResponse> { - return this.openAICompletion(messages, modelId, temperature, maxTokens) + try { + return await this.openAICompletion(messages, modelId, temperature, maxTokens) + } catch (err) { + console.error('[ERROR]', { + ts: new Date().toISOString(), + level: 'ERROR', + code: 'DOUBAO_COMPLETIONS_ERROR', + provider: this.provider.id, + modelId, + message: err instanceof Error ? err.message : String(err), + stack: err instanceof Error ? err.stack : undefined + }) + throw err + } } @@ async generateText( prompt: string, modelId: string, temperature?: number, maxTokens?: number ): Promise<LLMResponse> { - return this.openAICompletion( - [ - { - role: 'user', - content: prompt - } - ], - modelId, - temperature, - maxTokens - ) + try { + return await this.openAICompletion( + [{ role: 'user', content: prompt }], + modelId, + temperature, + maxTokens + ) + } catch (err) { + console.error('[ERROR]', { + ts: new Date().toISOString(), + level: 'ERROR', + code: 'DOUBAO_GENERATE_TEXT_ERROR', + provider: this.provider.id, + modelId, + message: err instanceof Error ? err.message : String(err), + stack: err instanceof Error ? err.stack : undefined + }) + throw err + } }Also applies to: 164-181
🧹 Nitpick comments (2)
src/main/presenter/configPresenter/providerModelSettings.ts (1)
176-184: Standardize display names (remove mixed date parentheticals).Name formatting is inconsistent; two entries append dates in parentheses while peers don’t. Unify for UX consistency.
- name: 'Doubao Seed 1.6 Flash (250615)', + name: 'Doubao Seed 1.6 Flash', @@ - name: 'Doubao Seed 1.6 Thinking (250615)', + name: 'Doubao Seed 1.6 Thinking',Also applies to: 198-206
src/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts (1)
118-118: Standardize model names (remove date parentheses).Keep naming consistent with other entries.
- name: 'doubao-seed-1.6-flash (250615)', + name: 'doubao-seed-1.6-flash', @@ - name: 'doubao-seed-1.6-thinking (250615)', + name: 'doubao-seed-1.6-thinking',Also applies to: 142-142
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/main/presenter/configPresenter/providerModelSettings.ts(1 hunks)src/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写
Files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
src/{main,renderer}/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
src/{main,renderer}/**/*.ts: Use context isolation for improved security
Implement proper inter-process communication (IPC) patterns
Optimize application startup time with lazy loading
Implement proper error handling and logging for debugging
Files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
src/main/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)
Use Electron's built-in APIs for file system and native dialogs
From main to renderer, broadcast events via EventBus using mainWindow.webContents.send()
Files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)
**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别Enable and adhere to strict TypeScript type checking
Files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
src/main/**/*.{ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
主进程代码放在
src/main
Files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
src/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for all logs and comments
Files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
src/main/presenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain one presenter per functional domain in src/main/presenter/
Files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
src/main/presenter/configPresenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Centralize configuration logic under configPresenter/
Files:
src/main/presenter/configPresenter/providerModelSettings.ts
src/main/presenter/llmProviderPresenter/providers/*.ts
📄 CodeRabbit inference engine (.cursor/rules/llm-agent-loop.mdc)
src/main/presenter/llmProviderPresenter/providers/*.ts: Each file insrc/main/presenter/llmProviderPresenter/providers/*.tsshould handle interaction with a specific LLM API, including request/response formatting, tool definition conversion, native/non-native tool call management, and standardizing output streams to a common event format.
Provider implementations must use acoreStreammethod that yields standardized stream events to decouple the main loop from provider-specific details.
ThecoreStreammethod in each Provider must perform a single streaming API request per conversation round and must not contain multi-round tool call loop logic.
Provider files should implement helper methods such asformatMessages,convertToProviderTools,parseFunctionCalls, andprepareFunctionCallPromptas needed for provider-specific logic.
All provider implementations must parse provider-specific data chunks and yield standardized events for text, reasoning, tool calls, usage, errors, stop reasons, and image data.
When a provider does not support native function calling, it must prepare messages using prompt wrapping (e.g.,prepareFunctionCallPrompt) before making the API call.
When a provider supports native function calling, MCP tools must be converted to the provider's format (e.g., usingconvertToProviderTools) and included in the API request.
Provider implementations should aggregate and yield usage events as part of the standardized stream.
Provider implementations should yield image data events in the standardized format when applicable.
Provider implementations should yield reasoning events in the standardized format when applicable.
Provider implementations should yield tool call events (tool_call_start,tool_call_chunk,tool_call_end) in the standardized format.
Provider implementations should yield stop events with appropriatestop_reasonin the standardized format.
Provider implementations should yield error events in the standardized format...
Files:
src/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
🧠 Learnings (1)
📚 Learning: 2025-08-26T14:13:46.601Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-26T14:13:46.601Z
Learning: Applies to src/main/presenter/configPresenter/providers.ts : Add new provider configuration entries in configPresenter/providers.ts
Applied to files:
src/main/presenter/configPresenter/providerModelSettings.tssrc/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts
🔇 Additional comments (1)
src/main/presenter/llmProviderPresenter/providers/doubaoProvider.ts (1)
18-78: Verify tool conversion and image support in DoubaoProvider
DoubaoProvider extends OpenAICompatibleProvider, but OpenAICompatibleProvider.coreStream must convert MCP tools (via convertToProviderTools) and include image payloads for vision-enabled models. Confirm coreStream applies mcpTools correctly and respects each model’s vision flag; if not, add provider-specific overrides (e.g. convertToProviderTools/formatMessages) in doubaoProvider.ts.
| id: 'doubao-seed-1-6-vision-250815', | ||
| name: 'Doubao Seed 1.6 Vision', | ||
| temperature: 0.7, | ||
| maxTokens: 32000, | ||
| contextLength: 256000, | ||
| match: ['doubao-seed-1-6-vision-250815', 'doubao-seed-1.6-vision'], | ||
| vision: true, | ||
| functionCall: true, | ||
| reasoning: true | ||
| }, | ||
| { | ||
| id: 'doubao-seed-1-6-250615', | ||
| name: 'Doubao Seed 1.6', | ||
| temperature: 0.7, | ||
| maxTokens: 32000, | ||
| contextLength: 256000, | ||
| match: ['doubao-seed-1-6-250615', 'doubao-seed-1.6'], | ||
| vision: true, | ||
| functionCall: true, | ||
| reasoning: true | ||
| }, | ||
| { | ||
| id: 'doubao-seed-1-6-flash-250715', | ||
| name: 'Doubao Seed 1.6 Flash', | ||
| temperature: 0.7, | ||
| maxTokens: 32000, | ||
| contextLength: 256000, | ||
| match: ['doubao-seed-1-6-flash-250715', 'doubao-seed-1.6-flash'], | ||
| vision: true, | ||
| functionCall: true, | ||
| reasoning: true | ||
| }, | ||
| { | ||
| id: 'doubao-seed-1-6-flash-250615', | ||
| name: 'Doubao Seed 1.6 Flash (250615)', | ||
| temperature: 0.7, | ||
| maxTokens: 32000, | ||
| contextLength: 256000, | ||
| match: ['doubao-seed-1-6-flash-250615'], | ||
| vision: true, | ||
| functionCall: true, | ||
| reasoning: true | ||
| }, | ||
| { | ||
| id: 'doubao-seed-1-6-thinking-250715', | ||
| name: 'Doubao Seed 1.6 Thinking', | ||
| temperature: 0.7, | ||
| maxTokens: 32000, | ||
| contextLength: 256000, | ||
| match: ['doubao-seed-1-6-thinking-250715', 'doubao-seed-1.6-thinking'], | ||
| vision: true, | ||
| functionCall: true, | ||
| reasoning: true | ||
| }, | ||
| { | ||
| id: 'doubao-seed-1-6-thinking-250615', | ||
| name: 'Doubao Seed 1.6 Thinking (250615)', | ||
| temperature: 0.7, | ||
| maxTokens: 32000, | ||
| contextLength: 256000, | ||
| match: ['doubao-seed-1-6-thinking-250615'], | ||
| vision: true, | ||
| functionCall: true, | ||
| reasoning: true | ||
| } |
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.
💡 Verification agent
🧩 Analysis chain
Verify capability flags against Doubao API (functionCall/vision/reasoning).
All Doubao Seed entries set functionCall: true and vision: true. Confirm these are natively supported and exercised by our provider path; otherwise we should disable or prompt-wrap.
Run:
Expected: Doubao path (or its base) handles tool conversion and image parts. If absent, we must either implement conversion/wrapping here or flip functionCall/vision to false for the affected models.
🏁 Script executed:
#!/bin/bash
# Check provider/tooling support for native function calling & vision under Doubao
rg -n -C2 -e 'convertToProviderTools|prepareFunctionCallPrompt|image_url|content: \[{ type: "image_url"' src/main/presenter/llmProviderPresenter/providersLength of output: 400
🏁 Script executed:
#!/bin/bash
# Corrected patterns: list provider files and search for functionCall & vision support in Doubao provider
echo "Provider files under src/main/presenter/llmProviderPresenter/providers:"
fd -t f src/main/presenter/llmProviderPresenter/providers
echo -e "\nLooking for convertToProviderTools usage:"
rg -n -C2 'convertToProviderTools' src/main/presenter/llmProviderPresenter/providers
echo -e "\nLooking for prepareFunctionCallPrompt usage:"
rg -n -C2 'prepareFunctionCallPrompt' src/main/presenter/llmProviderPresenter/providers
echo -e "\nLooking for image_url or vision handling:"
rg -n -C2 'image_url' src/main/presenter/llmProviderPresenter/providersLength of output: 21879
🏁 Script executed:
#!/bin/bash
# List all provider files
fd . src/main/presenter/llmProviderPresenter/providers
# Locate Doubao provider file(s)
echo "Doubao provider files:"
fd doubao src/main/presenter/llmProviderPresenter/providers
# Inspect Doubao provider for native tool conversion & vision support
for file in $(fd doubao src/main/presenter/llmProviderPresenter/providers); do
echo -e "\n=== Inspecting $file ==="
rg -n 'convertToProviderTools' $file || echo "⚠️ no convertToProviderTools usage"
rg -n 'prepareFunctionCallPrompt' $file || echo "⚠️ no prepareFunctionCallPrompt usage"
rg -n -C2 'vision' $file || echo "⚠️ no vision flag handling"
rg -n -C2 'image_url' $file || echo "⚠️ no image_url handling"
doneLength of output: 4338
Implement Doubao native tooling/vision support or disable flags
providerModelSettings.ts (lines 143–207) defines all Doubao Seed entries with functionCall: true and vision: true, but doubaoProvider.ts lacks
– any use of convertToProviderTools or prepareFunctionCallPrompt
– handling of incoming image_url content
Either extend doubaoProvider.ts to convert tools and process images natively or set functionCall/vision to false for those models.
update Doubao provider with new models

Summary by CodeRabbit