mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
fix(dashscope): forward user param in embed, honour api_base in rerank URL, and unify API-key env fallback across embed/rerank
This commit is contained in:
parent
9f7763edd4
commit
5495d70ba0
2 changed files with 8 additions and 3 deletions
|
|
@ -73,7 +73,11 @@ class DashScopeEmbeddingConfig(BaseEmbeddingConfig):
|
|||
api_base: Optional[str] = None,
|
||||
) -> dict:
|
||||
if api_key is None:
|
||||
raise ValueError("api_key is required for DashScope authentication")
|
||||
api_key = get_secret_str("DASHSCOPE_API_KEY")
|
||||
if api_key is None:
|
||||
raise ValueError(
|
||||
"DashScope API key is required. Set 'DASHSCOPE_API_KEY' env var or pass api_key explicitly."
|
||||
)
|
||||
default_headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {api_key}",
|
||||
|
|
@ -106,7 +110,7 @@ class DashScopeEmbeddingConfig(BaseEmbeddingConfig):
|
|||
"model": model,
|
||||
"input": input,
|
||||
}
|
||||
for key in ("dimensions", "encoding_format"):
|
||||
for key in ("dimensions", "encoding_format", "user"):
|
||||
value = optional_params.get(key)
|
||||
if value is not None:
|
||||
data[key] = value
|
||||
|
|
|
|||
|
|
@ -77,7 +77,8 @@ class DashScopeRerankConfig(BaseRerankConfig):
|
|||
if cleaned.endswith("/v1"):
|
||||
return f"{cleaned}/reranks"
|
||||
|
||||
return DEFAULT_RERANK_URL
|
||||
# Unknown base: append /reranks rather than silently ignoring the caller's api_base.
|
||||
return f"{cleaned}/reranks"
|
||||
|
||||
def validate_environment(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue