Skip to content

Commit e092920

Browse files
authored
Merge pull request #470 from M87shaonv/main
Added siliconflow API support
2 parents d390e68 + 61de4e8 commit e092920

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ MOONSHOT_API_KEY=
2727
UNBOUND_ENDPOINT=https://api.getunbound.ai
2828
UNBOUND_API_KEY=
2929

30+
SiliconFLOW_ENDPOINT=https://api.siliconflow.cn/v1/
31+
SiliconFLOW_API_KEY=
32+
3033
# Set to false to disable anonymized telemetry
3134
ANONYMIZED_TELEMETRY=false
3235

src/utils/llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
Literal,
3838
Optional,
3939
Union,
40-
cast,
40+
cast, List,
4141
)
4242

4343

src/utils/utils.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,24 @@ def get_llm_model(provider: str, **kwargs):
165165
return ChatOpenAI(
166166
model=kwargs.get("model_name", "gpt-4o-mini"),
167167
temperature=kwargs.get("temperature", 0.0),
168-
base_url = os.getenv("UNBOUND_ENDPOINT", "https://api.getunbound.ai"),
168+
base_url=os.getenv("UNBOUND_ENDPOINT", "https://api.getunbound.ai"),
169169
api_key=api_key,
170170
)
171+
elif provider == "siliconflow":
172+
if not kwargs.get("api_key", ""):
173+
api_key = os.getenv("SiliconFLOW_API_KEY", "")
174+
else:
175+
api_key = kwargs.get("api_key")
176+
if not kwargs.get("base_url", ""):
177+
base_url = os.getenv("SiliconFLOW_ENDPOINT", "")
178+
else:
179+
base_url = kwargs.get("base_url")
180+
return ChatOpenAI(
181+
api_key=api_key,
182+
base_url=base_url,
183+
model_name=kwargs.get("model_name", "Qwen/QwQ-32B"),
184+
temperature=kwargs.get("temperature", 0.0),
185+
)
171186
else:
172187
raise ValueError(f"Unsupported provider: {provider}")
173188

@@ -185,7 +200,40 @@ def get_llm_model(provider: str, **kwargs):
185200
"mistral": ["pixtral-large-latest", "mistral-large-latest", "mistral-small-latest", "ministral-8b-latest"],
186201
"alibaba": ["qwen-plus", "qwen-max", "qwen-turbo", "qwen-long"],
187202
"moonshot": ["moonshot-v1-32k-vision-preview", "moonshot-v1-8k-vision-preview"],
188-
"unbound": ["gemini-2.0-flash","gpt-4o-mini", "gpt-4o", "gpt-4.5-preview"]
203+
"unbound": ["gemini-2.0-flash", "gpt-4o-mini", "gpt-4o", "gpt-4.5-preview"],
204+
"siliconflow": [
205+
"deepseek-ai/DeepSeek-R1",
206+
"deepseek-ai/DeepSeek-V3",
207+
"deepseek-ai/DeepSeek-R1-Distill-Qwen-32B",
208+
"deepseek-ai/DeepSeek-R1-Distill-Qwen-14B",
209+
"deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
210+
"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
211+
"deepseek-ai/DeepSeek-V2.5",
212+
"deepseek-ai/deepseek-vl2",
213+
"Qwen/Qwen2.5-72B-Instruct-128K",
214+
"Qwen/Qwen2.5-72B-Instruct",
215+
"Qwen/Qwen2.5-32B-Instruct",
216+
"Qwen/Qwen2.5-14B-Instruct",
217+
"Qwen/Qwen2.5-7B-Instruct",
218+
"Qwen/Qwen2.5-Coder-32B-Instruct",
219+
"Qwen/Qwen2.5-Coder-7B-Instruct",
220+
"Qwen/Qwen2-7B-Instruct",
221+
"Qwen/Qwen2-1.5B-Instruct",
222+
"Qwen/QwQ-32B-Preview",
223+
"Qwen/Qwen2-VL-72B-Instruct",
224+
"Qwen/Qwen2.5-VL-32B-Instruct",
225+
"Qwen/Qwen2.5-VL-72B-Instruct",
226+
"TeleAI/TeleChat2",
227+
"THUDM/glm-4-9b-chat",
228+
"Vendor-A/Qwen/Qwen2.5-72B-Instruct",
229+
"internlm/internlm2_5-7b-chat",
230+
"internlm/internlm2_5-20b-chat",
231+
"Pro/Qwen/Qwen2.5-7B-Instruct",
232+
"Pro/Qwen/Qwen2-7B-Instruct",
233+
"Pro/Qwen/Qwen2-1.5B-Instruct",
234+
"Pro/THUDM/chatglm3-6b",
235+
"Pro/THUDM/glm-4-9b-chat",
236+
],
189237
}
190238

191239

0 commit comments

Comments
 (0)