Skip to content

Commit b073b83

Browse files
authored
Merge pull request #287 from maquannene/feat/qwen-support
Feat/qwen support
2 parents 84b8965 + 3e7551c commit b073b83

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ MISTRAL_ENDPOINT=https://api.mistral.ai/v1
1818

1919
OLLAMA_ENDPOINT=http://localhost:11434
2020

21+
ALIBABA_ENDPOINT=https://dashscope.aliyuncs.com/compatible-mode/v1
22+
ALIBABA_API_KEY=
23+
2124
# Set to false to disable anonymized telemetry
2225
ANONYMIZED_TELEMETRY=true
2326

src/utils/utils.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"azure_openai": "Azure OpenAI",
2020
"anthropic": "Anthropic",
2121
"deepseek": "DeepSeek",
22-
"google": "Google"
22+
"google": "Google",
23+
"alibaba": "Alibaba"
2324
}
2425

2526
def get_llm_model(provider: str, **kwargs):
@@ -136,9 +137,21 @@ def get_llm_model(provider: str, **kwargs):
136137
azure_endpoint=base_url,
137138
api_key=api_key,
138139
)
140+
elif provider == "alibaba":
141+
if not kwargs.get("base_url", ""):
142+
base_url = os.getenv("ALIBABA_ENDPOINT", "https://dashscope.aliyuncs.com/compatible-mode/v1")
143+
else:
144+
base_url = kwargs.get("base_url")
145+
146+
return ChatOpenAI(
147+
model=kwargs.get("model_name", "qwen-plus"),
148+
temperature=kwargs.get("temperature", 0.0),
149+
base_url=base_url,
150+
api_key=api_key,
151+
)
139152
else:
140153
raise ValueError(f"Unsupported provider: {provider}")
141-
154+
142155
# Predefined model names for common providers
143156
model_names = {
144157
"anthropic": ["claude-3-5-sonnet-20240620", "claude-3-opus-20240229"],
@@ -147,7 +160,8 @@ def get_llm_model(provider: str, **kwargs):
147160
"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"],
148161
"ollama": ["qwen2.5:7b", "llama2:7b", "deepseek-r1:14b", "deepseek-r1:32b"],
149162
"azure_openai": ["gpt-4o", "gpt-4", "gpt-3.5-turbo"],
150-
"mistral": ["pixtral-large-latest", "mistral-large-latest", "mistral-small-latest", "ministral-8b-latest"]
163+
"mistral": ["pixtral-large-latest", "mistral-large-latest", "mistral-small-latest", "ministral-8b-latest"],
164+
"alibaba": ["qwen-plus", "qwen-max", "qwen-turbo", "qwen-long"]
151165
}
152166

153167
# Callback to update the model name dropdown based on the selected provider

tests/test_llm_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def get_env_value(key, provider):
4040
"google": {"api_key": "GOOGLE_API_KEY"},
4141
"deepseek": {"api_key": "DEEPSEEK_API_KEY", "base_url": "DEEPSEEK_ENDPOINT"},
4242
"mistral": {"api_key": "MISTRAL_API_KEY", "base_url": "MISTRAL_ENDPOINT"},
43+
"alibaba": {"api_key": "ALIBABA_API_KEY", "base_url": "ALIBABA_ENDPOINT"},
4344
}
4445

4546
if provider in env_mappings and key in env_mappings[provider]:

0 commit comments

Comments
 (0)