@@ -220,6 +220,48 @@ async def check_llm_status(data: dict) -> dict:
220220 resp .raise_for_status ()
221221 return {"success" : True , "message" : "连接成功" }
222222
223+ # MiniMax 特殊处理
224+ elif supplier == 10 : # MiniMax
225+ # MiniMax 使用兼容OpenAI的API,但可能有特定的端点要求
226+ domain = api_domain
227+
228+ # 根据搜索结果,MiniMax的API端点可能不是标准的/models
229+ # 尝试使用更简单的连接测试方法
230+ url = f"{ domain } /models"
231+ headers = {"Content-Type" : "application/json" }
232+ if api_key :
233+ headers ["Authorization" ] = f"Bearer { api_key } "
234+
235+ try :
236+ async with httpx .AsyncClient () as client :
237+ resp = await client .get (url , headers = headers , timeout = 10 )
238+ resp .raise_for_status ()
239+ return {"success" : True , "message" : "连接成功" }
240+ except httpx .HTTPStatusError as e :
241+ if e .response .status_code == 404 :
242+ # 对于MiniMax,如果/models端点不存在,尝试直接测试连接
243+ # 使用一个简单的HEAD请求来测试网络连接
244+ try :
245+ async with httpx .AsyncClient () as client :
246+ # 尝试对基础域名进行连接测试
247+ base_domain = domain .replace ('/v1' , '' )
248+ resp = await client .head (base_domain , timeout = 5 )
249+ # 如果能连接到域名,说明配置基本正确
250+ return {"success" : True , "message" : "连接成功" }
251+ except :
252+ return {"success" : False , "message" : "无法连接到API域名,请检查网络和域名配置" }
253+ elif e .response .status_code == 401 :
254+ return {"success" : False , "message" : "API Key 无效或未授权" }
255+ else :
256+ return {"success" : False , "message" : f"连接失败: HTTP { e .response .status_code } " }
257+ except httpx .TimeoutException :
258+ return {"success" : False , "message" : "连接超时,请检查网络或API域名" }
259+ except httpx .ConnectError :
260+ return {"success" : False , "message" : "无法连接到服务器,请检查API域名" }
261+ except Exception as e :
262+ logger .error (f"MiniMax连接测试失败: { e } " )
263+ return {"success" : False , "message" : f"连接失败: { str (e )} " }
264+
223265 # 其他供应商(DeepSeek, Qwen, Moonshot, ZhipuAI 等)
224266 else :
225267 # 尝试使用 OpenAI 兼容协议测试
@@ -237,6 +279,9 @@ async def check_llm_status(data: dict) -> dict:
237279 if e .response .status_code == 401 :
238280 return {"success" : False , "message" : "API Key 无效或未授权" }
239281 elif e .response .status_code == 404 :
282+ # 对于MiniMax等供应商,可能需要特殊处理
283+ if supplier == 10 : # MiniMax
284+ return {"success" : False , "message" : "API 端点不存在,请检查 API 域名。MiniMax 可能需要使用完整的模型列表端点" }
240285 return {"success" : False , "message" : "API 端点不存在,请检查 API 域名" }
241286 else :
242287 return {"success" : False , "message" : f"连接失败: HTTP { e .response .status_code } " }
@@ -309,6 +354,30 @@ async def fetch_base_models(supplier: int, api_key: str = None, api_domain: str
309354 models = [m ['id' ] for m in data .get ('data' , [])]
310355 return sorted (models )
311356
357+ # MiniMax
358+ elif supplier == 10 :
359+ if not api_key :
360+ return []
361+ domain = api_domain or "https://api.minimaxi.com/v1"
362+ url = f"{ domain } /models"
363+ headers = {"Authorization" : f"Bearer { api_key } " }
364+
365+ try :
366+ async with httpx .AsyncClient () as client :
367+ resp = await client .get (url , headers = headers , timeout = 10 )
368+ resp .raise_for_status ()
369+ data = resp .json ()
370+ # 根据OpenAI兼容API格式提取模型列表
371+ if 'data' in data :
372+ models = [m ['id' ] for m in data .get ('data' , [])]
373+ else :
374+ # 如果没有data字段,尝试其他格式
375+ models = [m ['id' ] for m in data ] if isinstance (data , list ) else []
376+ return sorted (models )
377+ except :
378+ # 如果获取模型列表失败,返回一些常见的MiniMax模型名称
379+ return ["MiniMax-M2.1" , "abab6.5s-chat" , "abab5.5-chat" ]
380+
312381 # Fallback or other providers: Return empty list or hardcoded common ones?
313382 # For now return empty, frontend can allow manual entry
314383 return []
0 commit comments