feat: support alibaba qwen llm;
This commit is contained in:
@@ -17,6 +17,9 @@ MISTRAL_ENDPOINT=https://api.mistral.ai/v1
|
||||
|
||||
OLLAMA_ENDPOINT=http://localhost:11434
|
||||
|
||||
ALIBABA_ENDPOINT=https://dashscope.aliyuncs.com/compatible-mode/v1
|
||||
ALIBABA_API_KEY=
|
||||
|
||||
# Set to false to disable anonymized telemetry
|
||||
ANONYMIZED_TELEMETRY=true
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ PROVIDER_DISPLAY_NAMES = {
|
||||
"azure_openai": "Azure OpenAI",
|
||||
"anthropic": "Anthropic",
|
||||
"deepseek": "DeepSeek",
|
||||
"google": "Google"
|
||||
"google": "Google",
|
||||
"alibaba": "Alibaba"
|
||||
}
|
||||
|
||||
def get_llm_model(provider: str, **kwargs):
|
||||
@@ -135,9 +136,21 @@ def get_llm_model(provider: str, **kwargs):
|
||||
azure_endpoint=base_url,
|
||||
api_key=api_key,
|
||||
)
|
||||
elif provider == "alibaba":
|
||||
if not kwargs.get("base_url", ""):
|
||||
base_url = os.getenv("ALIBABA_ENDPOINT", "https://dashscope.aliyuncs.com/compatible-mode/v1")
|
||||
else:
|
||||
base_url = kwargs.get("base_url")
|
||||
|
||||
return ChatOpenAI(
|
||||
model=kwargs.get("model_name", "qwen-plus"),
|
||||
temperature=kwargs.get("temperature", 0.0),
|
||||
base_url=base_url,
|
||||
api_key=api_key,
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Unsupported provider: {provider}")
|
||||
|
||||
|
||||
# Predefined model names for common providers
|
||||
model_names = {
|
||||
"anthropic": ["claude-3-5-sonnet-20240620", "claude-3-opus-20240229"],
|
||||
@@ -146,7 +159,8 @@ model_names = {
|
||||
"google": ["gemini-2.0-flash-exp", "gemini-2.0-flash-thinking-exp", "gemini-1.5-flash-latest", "gemini-1.5-flash-8b-latest", "gemini-2.0-flash-thinking-exp-01-21"],
|
||||
"ollama": ["qwen2.5:7b", "llama2:7b", "deepseek-r1:14b", "deepseek-r1:32b"],
|
||||
"azure_openai": ["gpt-4o", "gpt-4", "gpt-3.5-turbo"],
|
||||
"mistral": ["pixtral-large-latest", "mistral-large-latest", "mistral-small-latest", "ministral-8b-latest"]
|
||||
"mistral": ["pixtral-large-latest", "mistral-large-latest", "mistral-small-latest", "ministral-8b-latest"],
|
||||
"alibaba": ["qwen-plus", "qwen-max", "qwen-turbo", "qwen-long"]
|
||||
}
|
||||
|
||||
# Callback to update the model name dropdown based on the selected provider
|
||||
|
||||
@@ -40,6 +40,7 @@ def get_env_value(key, provider):
|
||||
"google": {"api_key": "GOOGLE_API_KEY"},
|
||||
"deepseek": {"api_key": "DEEPSEEK_API_KEY", "base_url": "DEEPSEEK_ENDPOINT"},
|
||||
"mistral": {"api_key": "MISTRAL_API_KEY", "base_url": "MISTRAL_ENDPOINT"},
|
||||
"alibaba": {"api_key": "ALIBABA_API_KEY", "base_url": "ALIBABA_ENDPOINT"},
|
||||
}
|
||||
|
||||
if provider in env_mappings and key in env_mappings[provider]:
|
||||
|
||||
Reference in New Issue
Block a user