fix(llm): Tongyi-Qianwen embeddings use correct DashScope native API for intl URLs (#14784)

## Summary
- Fixes **Tongyi-Qianwen** (`QWenEmbed`) text embeddings when the
configured `base_url` points at DashScope **international**
(`dashscope-intl.aliyuncs.com`) or **China** (`dashscope.aliyuncs.com`)
hosts, including values copied from Model Studio that use the
**OpenAI-compatible** path (`.../compatible-mode/v1`).
- The `dashscope` Python SDK (`TextEmbedding.call`) expects the
**native** HTTP root (`https://<host>/api/v1`), not the
OpenAI-compatible base URL. Without mapping, international accounts
could hit the wrong host or path.

## Implementation
- Added `_dashscope_native_http_api_url()` to normalize known DashScope
hosts to `.../api/v1`, and wired `QWenEmbed` to set
`dashscope.base_http_api_url` before each embedding call (document and
query).

## Notes
- In-code comments document the Tongyi-Qianwen / DashScope intl vs CN
behavior for future maintainers.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
sham-sr
2026-05-15 07:07:48 +05:00
committed by GitHub
parent d887b578c5
commit ef2969a462
2 changed files with 89 additions and 4 deletions

1
.gitignore vendored
View File

@@ -21,6 +21,7 @@ Cargo.lock
.idea/
.vscode/
.cursor/settings.json
# Exclude Mac generated files
.DS_Store