Skip to content

feat(auth): add Alibaba DashScope provider - #78

Merged
elkaix merged 6 commits into
mainfrom
feat/alibaba-dashscope-minimax-m3
Jun 4, 2026
Merged

feat(auth): add Alibaba DashScope provider#78
elkaix merged 6 commits into
mainfrom
feat/alibaba-dashscope-minimax-m3

Conversation

@elkaix

@elkaix elkaix commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary

  • add Alibaba Model Studio / DashScope API-key provider with Token Plan model catalog
  • normalize DashScope workspace base URLs and wire Alibaba into shell login/model flows
  • mark GLM native-thinking models as always_thinking
  • update MiniMax catalog to default to MiniMax M3 with native multimodal capabilities

Verification

  • uv run python -m pytest tests/auth/ tests/core/test_create_llm.py -q
  • uv run python -m pytest tests/auth/test_minimax_auth.py tests/auth/test_platforms.py -q
  • uv run ruff check src/pythinker_code/auth/alibaba.py src/pythinker_code/llm.py tests/auth/test_alibaba_auth.py tests/core/test_create_llm.py
  • uv run ruff check src/pythinker_code/auth/minimax.py tests/auth/test_minimax_auth.py tests/auth/test_platforms.py
  • uv run pyright src/pythinker_code/auth/alibaba.py src/pythinker_code/llm.py tests/auth/test_alibaba_auth.py tests/core/test_create_llm.py
  • uv run pyright src/pythinker_code/auth/minimax.py tests/auth/test_minimax_auth.py tests/auth/test_platforms.py

Summary by CodeRabbit

  • New Features

    • Added Alibaba (DashScope) provider with model discovery and API-key login/logout flows
    • CLI: added alibaba mode for login/logout
  • Improvements

    • Enabled provider-specific GLM thinking controls for reasoning behavior
    • MiniMax default upgraded to M3 with larger context and expanded multimodal capabilities
  • Tests

    • Expanded tests covering Alibaba integration, GLM thinking behavior, and MiniMax M3 changes

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 16cf654b-df11-46d4-bd1e-45489cf054a8

📥 Commits

Reviewing files that changed from the base of the PR and between aa9d3b9 and 8d652f7.

📒 Files selected for processing (1)
  • tests/auth/test_alibaba_auth.py

📝 Walkthrough

Walkthrough

Adds Alibaba (DashScope) OAuth provider with model discovery, upgrades MiniMax defaults to the M3 catalog with larger contexts and capabilities, and routes GLM/Kimi models to provider-specific thinking controls in create_llm.

Changes

Alibaba DashScope and Model/Provider Enhancements

Layer / File(s) Summary
Alibaba platform constants and module exports
src/pythinker_code/auth/__init__.py
Defines and exports ALIBABA_PLATFORM_ID = "alibaba".
Alibaba model catalog and environment resolution
src/pythinker_code/auth/alibaba.py
Adds AlibabaModel, ALIBABA_MODELS, and env helpers to read DASHSCOPE_API_KEY and normalize base URLs to /compatible-mode/v1.
Alibaba login, logout, and discovery
src/pythinker_code/auth/alibaba.py
Implements async login_alibaba_api_key and logout_alibaba, remote /models discovery (aiohttp), parsing, config mutation, error handling (401/403 vs network), fallback to static catalog, and logout cleanup.
OAuth shell integration for Alibaba
src/pythinker_code/ui/shell/oauth.py
Adds Alibaba to CLI provider selectors, maps provider key/status, implements /login alibaba and /logout alibaba branches, and updates usage text.
Alibaba authentication test coverage
tests/auth/test_alibaba_auth.py
New comprehensive tests: static catalog, env handling, base-URL normalization, _apply_alibaba_config, discovery success/failure/auth errors, parsing rules, and logout behavior.
MiniMax M3 upgrade
src/pythinker_code/auth/minimax.py, tests/auth/test_minimax_auth.py, tests/auth/test_platforms.py
Changes default to minimax/m3, raises default/fallback context sizes, adds M3 capability/context constants, prepends M3 model to MINIMAX_MODELS, and updates tests accordingly.
GLM provider-specific thinking control
src/pythinker_code/llm.py, tests/core/test_create_llm.py
Adds _is_glm_model() and sends provider-specific extra_body.thinking for GLM/Kimi models (GLM sets clear_thinking=False when enabled); adds tests for glm-5.1 enabled/disabled thinking.
Changelog
CHANGELOG.md
Adds Unreleased note describing Alibaba DashScope support and MiniMax M3 defaulting.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

enhancement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.63% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title follows conventional commits format (feat(auth): add Alibaba DashScope provider) and accurately describes the main change.
Description check ✅ Passed The PR description provides a clear summary of changes and verification steps, but is missing the template sections (Related Issue link, full Checklist).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/alibaba-dashscope-minimax-m3

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/auth/test_alibaba_auth.py`:
- Around line 181-184: The test currently patches the private helper
_discover_alibaba_models (via fake_discover + monkeypatch.setattr) which couples
the test to internals; instead stub the HTTP/session boundary used by that
helper (e.g., monkeypatch the aiohttp.ClientSession.request or .get used by
_discover_alibaba_models or use a library like aioresponses) to raise
aiohttp.ClientConnectionError, then drive the public login flow (the Alibaba
auth/login method under test) and assert observable outcomes (login events,
config changes) rather than inspecting or replacing _discover_alibaba_models;
update the other similar cases at the indicated ranges (203-211, 226-235,
252-264) the same way.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 381da6b8-7d24-4e3c-aea6-0595aae0669c

📥 Commits

Reviewing files that changed from the base of the PR and between e02ffc6 and 0444a82.

📒 Files selected for processing (9)
  • src/pythinker_code/auth/__init__.py
  • src/pythinker_code/auth/alibaba.py
  • src/pythinker_code/auth/minimax.py
  • src/pythinker_code/llm.py
  • src/pythinker_code/ui/shell/oauth.py
  • tests/auth/test_alibaba_auth.py
  • tests/auth/test_minimax_auth.py
  • tests/auth/test_platforms.py
  • tests/core/test_create_llm.py

Comment thread tests/auth/test_alibaba_auth.py Outdated
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.92857% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pythinker_code/auth/alibaba.py 90.00% 4 Missing and 5 partials ⚠️
src/pythinker_code/ui/shell/oauth.py 10.00% 7 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/auth/test_alibaba_auth.py`:
- Line 286: The test's assertion uses exact dict equality for kwargs["headers"],
which is fragile; update the assertion in tests/auth/test_alibaba_auth.py so it
only checks the Authorization header (e.g., assert
kwargs["headers"].get("Authorization") == "Bearer sk-test" or assert
"Authorization" in kwargs["headers"] and kwargs["headers"]["Authorization"] ==
"Bearer sk-test") instead of comparing the whole headers dict.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c7f1de2a-c1c9-479d-a8e8-a2bcd7d179ba

📥 Commits

Reviewing files that changed from the base of the PR and between 0444a82 and cae9c52.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • tests/auth/test_alibaba_auth.py

Comment thread tests/auth/test_alibaba_auth.py Outdated
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