Skip to content

feat: add DeepSeek and Qwen provider support#164

Closed
majiayu000 wants to merge 2 commits intosimular-ai:mainfrom
majiayu000:feat/qwen-deepseek-support
Closed

feat: add DeepSeek and Qwen provider support#164
majiayu000 wants to merge 2 commits intosimular-ai:mainfrom
majiayu000:feat/qwen-deepseek-support

Conversation

@majiayu000
Copy link
Copy Markdown

@majiayu000 majiayu000 commented Dec 30, 2025

Summary

  • Add LMMEngineDeepSeek for DeepSeek models (https://api.deepseek.com)
  • Add LMMEngineQwen for Qwen/Tongyi models via DashScope API

Usage

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

  • New Features
    • Added support for DeepSeek and Qwen as new LLM providers.
    • Integrated automatic retry/backoff for API failures and rate limits.
    • Added configurable temperature and token-limit handling per request.
    • Allow API credentials via parameters or environment variables.
    • Integrated both providers into existing inference and image/content handling flows.

✏️ Tip: You can customize this high-level summary in your review settings.

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Engine implementations
gui_agents/s3/core/engine.py
Adds LMMEngineDeepSeek and LMMEngineQwen subclasses of LMMEngine. Each: new __init__ (base_url, api_key, model, rate_limit, temperature), lazy llm_client creation using env-var fallbacks (DEEPSEEK_API_KEY, DASHSCOPE_API_KEY), default provider base URLs, and a generate method wrapped with backoff retries returning first choice content. Note: identical/duplicated class blocks appear in-file.
Factory & inference wiring
gui_agents/s3/core/mllm.py
Imports the two new engine classes; MLLM factory __init__ recognizes "deepseek" and "qwen" to instantiate respective engines; includes them in API-style inference isinstance checks so text/image message handling and role inference use the new engines.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop with keys and tiny feet,
Two engines join our meadow sweet.
DeepSeek digs and Qwen takes flight,
With gentle retries through day and night.
Hooray — more models in our light! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding support for two new LLM providers (DeepSeek and Qwen). It directly reflects the primary objective of the pull request.
Linked Issues check ✅ Passed The PR successfully implements the request from issue #158 by adding native LMMEngineDeepSeek and LMMEngineQwen classes with proper API key handling, endpoint configuration, and CLI/environment variable support.
Out of Scope Changes check ✅ Passed All changes are directly related to adding DeepSeek and Qwen provider support. No unrelated modifications or out-of-scope changes are introduced beyond the stated objectives.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 984db59 and c76a5fb.

📒 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)


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a 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

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2cb57fb and 984db59.

📒 Files selected for processing (2)
  • gui_agents/s3/core/engine.py
  • gui_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_url formatting.

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.com is the official stable base URL per DeepSeek API docs
  • Qwen: https://dashscope.aliyuncs.com/compatible-mode/v1 is the official endpoint for the China/Beijing region

Note: DashScope also provides an international variant at https://dashscope-intl.aliyuncs.com/compatible-mode/v1 for non-China regions, if needed.

Comment thread gui_agents/s3/core/engine.py
Comment thread gui_agents/s3/core/engine.py
…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>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 duplicate AzureOpenAI import.

AzureOpenAI is 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 LMMEngineDeepSeek implementation correctly follows the established engine pattern. The previously flagged issue regarding missing **kwargs in the API call (line 490) has been resolved—kwargs are now properly forwarded to chat.completions.create().

Note: The static analysis warning about unused kwargs at line 456 is a false positive, as kwargs are forwarded to the API call.


495-539: LGTM! Previous issue resolved.

The LMMEngineQwen implementation correctly follows the established engine pattern. The previously flagged issue regarding missing **kwargs in the API call (line 537) has been resolved—kwargs are now properly forwarded to chat.completions.create().

Note: The static analysis warning about unused kwargs at line 503 is a false positive, as kwargs are forwarded to the API call.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 984db59 and c76a5fb.

📒 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)

@Richard-Simular
Copy link
Copy Markdown
Collaborator

similar comment as #163

@Richard-Simular
Copy link
Copy Markdown
Collaborator

closing as changes will be included in #163

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.

Does this framework have plans to support Qwen and DeepSeek?

2 participants