mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-01 02:02:20 +00:00
fix: address PR review feedback for modelscope provider
This commit is contained in:
parent
76d880a93b
commit
4b357508a7
3 changed files with 23 additions and 8 deletions
|
|
@ -63,6 +63,7 @@ from litellm.constants import (
|
|||
replicate_models,
|
||||
clarifai_models,
|
||||
huggingface_models,
|
||||
modelscope_models,
|
||||
empower_models,
|
||||
together_ai_models,
|
||||
baseten_models,
|
||||
|
|
@ -625,7 +626,6 @@ aiml_models: Set = set()
|
|||
deepgram_models: Set = set()
|
||||
elevenlabs_models: Set = set()
|
||||
dashscope_models: Set = set()
|
||||
modelscope_models: Set = set()
|
||||
moonshot_models: Set = set()
|
||||
publicai_models: Set = set()
|
||||
v0_models: Set = set()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Translates from OpenAI's `/v1/chat/completions` to ModelScope's `/v1/chat/completions`
|
||||
"""
|
||||
|
||||
from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, overload
|
||||
from typing import Any, Coroutine, List, Literal, Optional, Tuple, Union, cast, overload
|
||||
|
||||
from litellm.secret_managers.main import get_secret_str
|
||||
from litellm.types.llms.openai import AllMessageValues
|
||||
|
|
@ -43,14 +43,13 @@ class ModelScopeChatConfig(OpenAIGPTConfig):
|
|||
Messages with non-text content (e.g. image_url for vision models)
|
||||
are kept as lists so the parent class can normalize them properly.
|
||||
"""
|
||||
messages = [cast(AllMessageValues, {**m}) for m in messages]
|
||||
for message in messages:
|
||||
if _has_non_text_content(message):
|
||||
continue
|
||||
content = message.get("content")
|
||||
if isinstance(content, list):
|
||||
message["content"] = "".join(
|
||||
item.get("text") or "" for item in content
|
||||
)
|
||||
message["content"] = "".join(item.get("text") or "" for item in content)
|
||||
|
||||
if is_async:
|
||||
return super()._transform_messages(
|
||||
|
|
@ -65,9 +64,7 @@ class ModelScopeChatConfig(OpenAIGPTConfig):
|
|||
self, api_base: Optional[str], api_key: Optional[str]
|
||||
) -> Tuple[Optional[str], Optional[str]]:
|
||||
api_base = (
|
||||
api_base
|
||||
or get_secret_str("MODELSCOPE_API_BASE")
|
||||
or self.DEFAULT_BASE_URL
|
||||
api_base or get_secret_str("MODELSCOPE_API_BASE") or self.DEFAULT_BASE_URL
|
||||
) # type: ignore
|
||||
dynamic_api_key = api_key or get_secret_str("MODELSCOPE_API_KEY")
|
||||
return api_base, dynamic_api_key
|
||||
|
|
|
|||
|
|
@ -1468,6 +1468,24 @@
|
|||
"interactions": true
|
||||
}
|
||||
},
|
||||
"modelscope": {
|
||||
"display_name": "ModelScope (`modelscope`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/modelscope",
|
||||
"endpoints": {
|
||||
"chat_completions": true,
|
||||
"messages": true,
|
||||
"responses": true,
|
||||
"embeddings": false,
|
||||
"image_generations": true,
|
||||
"audio_transcriptions": false,
|
||||
"audio_speech": false,
|
||||
"moderations": false,
|
||||
"batches": false,
|
||||
"rerank": false,
|
||||
"a2a": false,
|
||||
"interactions": false
|
||||
}
|
||||
},
|
||||
"moonshot": {
|
||||
"display_name": "Moonshot (`moonshot`)",
|
||||
"url": "https://docs.litellm.ai/docs/providers/moonshot",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue