mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-05 07:37:50 +00:00
fix(dashscope): let the image env var beat any shared DashScope base
This commit is contained in:
parent
2a48c69e3e
commit
8ddb3f7731
2 changed files with 16 additions and 2 deletions
|
|
@ -131,6 +131,8 @@ class DashScopeImageGenerationConfig(BaseImageGenerationConfig):
|
|||
stream: bool | None = None,
|
||||
) -> str:
|
||||
image_env_api_base: Final = self._image_api_base_env()
|
||||
if not api_base and image_env_api_base:
|
||||
return image_env_api_base
|
||||
configured_api_base: Final = api_base or self._configured_chat_api_base()
|
||||
if configured_api_base and configured_api_base.rstrip("/").endswith(DASHSCOPE_CHAT_COMPATIBLE_PATH):
|
||||
return image_env_api_base or self._default_image_api_base()
|
||||
|
|
@ -138,8 +140,8 @@ class DashScopeImageGenerationConfig(BaseImageGenerationConfig):
|
|||
return configured_api_base
|
||||
endpoints: Final = resolve_dashscope_endpoints(configured_api_base)
|
||||
if endpoints is not None:
|
||||
return (None if api_base else image_env_api_base) or f"{endpoints.origin}{DASHSCOPE_IMAGE_PATH}"
|
||||
return configured_api_base or image_env_api_base or self._default_image_api_base()
|
||||
return f"{endpoints.origin}{DASHSCOPE_IMAGE_PATH}"
|
||||
return configured_api_base or self._default_image_api_base()
|
||||
|
||||
def validate_environment(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -519,6 +519,18 @@ def test_litellm_image_generation_dashscope_end_to_end(model: str):
|
|||
),
|
||||
(None, "https://gateway.example.com/dashscope/images", "", "https://gateway.example.com/dashscope/images"),
|
||||
(None, "https://dashscope-us.aliyuncs.com", "https://images.example.com/generate", "https://images.example.com/generate"),
|
||||
(
|
||||
None,
|
||||
f"https://dashscope-us.aliyuncs.com{DASHSCOPE_IMAGE_PATH}",
|
||||
"https://images.example.com/generate",
|
||||
"https://images.example.com/generate",
|
||||
),
|
||||
(
|
||||
None,
|
||||
"https://gateway.example.com/dashscope/images",
|
||||
"https://images.example.com/generate",
|
||||
"https://images.example.com/generate",
|
||||
),
|
||||
(
|
||||
"https://dashscope-us.aliyuncs.com",
|
||||
"",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue