feat: add DeepSeek and Qwen provider support#164
feat: add DeepSeek and Qwen provider support#164majiayu000 wants to merge 2 commits intosimular-ai:mainfrom
Conversation
Add LMMEngineDeepSeek and LMMEngineQwen classes for native model support. - DeepSeek: Uses https://api.deepseek.com endpoint - Qwen: Uses DashScope API (https://dashscope.aliyuncs.com/compatible-mode/v1) Closes simular-ai#158 Signed-off-by: majiayu000 <1835304752@qq.com>
📝 WalkthroughWalkthroughAdds two new LLM engine classes, LMMEngineDeepSeek and LMMEngineQwen, and integrates them into the MLLM factory and inference flow. Each engine validates API keys, lazily constructs an OpenAI-compatible client with a provider-specific base URL, and implements a backoff-wrapped chat completion method. Duplicate class blocks present. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as Client
participant Engine as LMMEngineDeepSeek/Qwen
participant Env as Env (API_KEY)
participant API as External LLM API
Note over App,Engine: Request flow for chat completion
App->>Engine: generate(messages, temperature, max_new_tokens)
Engine->>Env: read API key (param or env)
Env-->>Engine: API key
Engine->>Engine: lazy init llm_client (base_url + api_key)
Engine->>API: chat.completions(model, messages, max_tokens, temperature, ...)
alt success
API-->>Engine: completion response
Engine-->>App: return first choice content
else transient error
API-->>Engine: error (rate/conn/api)
note right of Engine `#ffe6cc`: backoff.on_exception retries up to timeout
Engine->>API: retry request
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🪛 Ruff (0.14.10)gui_agents/s3/core/engine.py456-456: Unused method argument: (ARG002) 478-480: Avoid specifying long messages outside the exception class (TRY003) 503-503: Unused method argument: (ARG002) 525-527: Avoid specifying long messages outside the exception class (TRY003) 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
gui_agents/s3/core/engine.pygui_agents/s3/core/mllm.py
🧰 Additional context used
🧬 Code graph analysis (1)
gui_agents/s3/core/mllm.py (1)
gui_agents/s3/core/engine.py (6)
LMMEngineDeepSeek(448-491)LMMEngineHuggingFace(369-402)LMMEngineOpenAI(19-68)LMMEngineOpenRouter(204-250)LMMEngineParasail(405-445)LMMEngineQwen(494-537)
🪛 Ruff (0.14.10)
gui_agents/s3/core/engine.py
456-456: Unused method argument: kwargs
(ARG002)
474-474: Unused method argument: kwargs
(ARG002)
478-480: Avoid specifying long messages outside the exception class
(TRY003)
502-502: Unused method argument: kwargs
(ARG002)
520-520: Unused method argument: kwargs
(ARG002)
524-526: Avoid specifying long messages outside the exception class
(TRY003)
🔇 Additional comments (5)
gui_agents/s3/core/mllm.py (3)
8-8: LGTM! Import statements follow existing patterns.The new engine imports are properly added and maintain alphabetical ordering with other engine imports.
Also applies to: 13-13
40-43: LGTM! Engine routing follows established patterns.The routing logic for both DeepSeek and Qwen engines is consistent with other engine integrations and correctly passes engine_params to the constructors.
129-141: LGTM! Type checks correctly classify new engines.Both DeepSeek and Qwen engines are properly added to the API-style inference branch, which is correct since they use OpenAI-compatible endpoints with
image_urlformatting.gui_agents/s3/core/engine.py (2)
448-537: No duplicate class definitions found. LMMEngineDeepSeek (line 448) and LMMEngineQwen (line 494) are each defined only once in the file.Likely an incorrect or invalid review comment.
481-481: API endpoints are correct and current.Both base URLs are verified as official endpoints:
- DeepSeek:
https://api.deepseek.comis the official stable base URL per DeepSeek API docs- Qwen:
https://dashscope.aliyuncs.com/compatible-mode/v1is the official endpoint for the China/Beijing regionNote: DashScope also provides an international variant at
https://dashscope-intl.aliyuncs.com/compatible-mode/v1for non-China regions, if needed.
…wen engines This ensures consistency with other engine implementations (OpenAI, Gemini, OpenRouter, etc.) and allows callers to pass additional parameters like stop, top_p, etc. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
gui_agents/s3/core/engine.py (1)
5-12: Remove duplicateAzureOpenAIimport.
AzureOpenAIis imported on both lines 6 and 9. Remove the duplicate to clean up the imports.🔎 Proposed fix
from openai import ( AzureOpenAI, APIConnectionError, APIError, - AzureOpenAI, OpenAI, RateLimitError, )
♻️ Duplicate comments (2)
gui_agents/s3/core/engine.py (2)
448-492: LGTM! Previous issue resolved.The
LMMEngineDeepSeekimplementation correctly follows the established engine pattern. The previously flagged issue regarding missing**kwargsin the API call (line 490) has been resolved—kwargs are now properly forwarded tochat.completions.create().Note: The static analysis warning about unused
kwargsat line 456 is a false positive, as kwargs are forwarded to the API call.
495-539: LGTM! Previous issue resolved.The
LMMEngineQwenimplementation correctly follows the established engine pattern. The previously flagged issue regarding missing**kwargsin the API call (line 537) has been resolved—kwargs are now properly forwarded tochat.completions.create().Note: The static analysis warning about unused
kwargsat line 503 is a false positive, as kwargs are forwarded to the API call.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
gui_agents/s3/core/engine.py
🧰 Additional context used
🪛 Ruff (0.14.10)
gui_agents/s3/core/engine.py
456-456: Unused method argument: kwargs
(ARG002)
478-480: Avoid specifying long messages outside the exception class
(TRY003)
503-503: Unused method argument: kwargs
(ARG002)
525-527: Avoid specifying long messages outside the exception class
(TRY003)
|
similar comment as #163 |
|
closing as changes will be included in #163 |
Summary
LMMEngineDeepSeekfor DeepSeek models (https://api.deepseek.com)LMMEngineQwenfor Qwen/Tongyi models via DashScope APIUsage
DeepSeek
export DEEPSEEK_API_KEY=your_key agent_s \ --provider deepseek \ --model deepseek-chat \ ...Qwen
export DASHSCOPE_API_KEY=your_key agent_s \ --provider qwen \ --model qwen-vl-max \ ...Closes #158
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.