2025-11-26 21:11:12 +08:00
|
|
|
|
"""
|
|
|
|
|
|
LLM工厂类 - 统一创建和管理LLM适配器
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
|
|
|
|
|
使用 LiteLLM 作为主要适配器,支持大多数 LLM 提供商。
|
|
|
|
|
|
对于 API 格式特殊的提供商(百度、MiniMax、豆包),使用原生适配器。
|
2025-11-26 21:11:12 +08:00
|
|
|
|
"""
|
|
|
|
|
|
|
2025-11-28 16:41:39 +08:00
|
|
|
|
from typing import Dict, List
|
2025-11-26 21:11:12 +08:00
|
|
|
|
from .types import LLMConfig, LLMProvider, DEFAULT_MODELS
|
|
|
|
|
|
from .base_adapter import BaseLLMAdapter
|
|
|
|
|
|
from .adapters import (
|
2025-11-28 16:41:39 +08:00
|
|
|
|
LiteLLMAdapter,
|
2025-11-26 21:11:12 +08:00
|
|
|
|
BaiduAdapter,
|
|
|
|
|
|
MinimaxAdapter,
|
|
|
|
|
|
DoubaoAdapter,
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-28 16:41:39 +08:00
|
|
|
|
# 必须使用原生适配器的提供商(API 格式特殊)
|
|
|
|
|
|
NATIVE_ONLY_PROVIDERS = {
|
|
|
|
|
|
LLMProvider.BAIDU,
|
|
|
|
|
|
LLMProvider.MINIMAX,
|
|
|
|
|
|
LLMProvider.DOUBAO,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
class LLMFactory:
|
|
|
|
|
|
"""LLM工厂类"""
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
_adapters: Dict[str, BaseLLMAdapter] = {}
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
|
def create_adapter(cls, config: LLMConfig) -> BaseLLMAdapter:
|
|
|
|
|
|
"""创建LLM适配器实例"""
|
|
|
|
|
|
cache_key = cls._get_cache_key(config)
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
# 从缓存中获取
|
|
|
|
|
|
if cache_key in cls._adapters:
|
|
|
|
|
|
return cls._adapters[cache_key]
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
# 创建新的适配器实例
|
|
|
|
|
|
adapter = cls._instantiate_adapter(config)
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
# 缓存实例
|
|
|
|
|
|
cls._adapters[cache_key] = adapter
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
return adapter
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
|
def _instantiate_adapter(cls, config: LLMConfig) -> BaseLLMAdapter:
|
|
|
|
|
|
"""根据提供商类型实例化适配器"""
|
|
|
|
|
|
# 如果未指定模型,使用默认模型
|
|
|
|
|
|
if not config.model:
|
|
|
|
|
|
config.model = DEFAULT_MODELS.get(config.provider, "gpt-4o-mini")
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
|
|
|
|
|
# 对于必须使用原生适配器的提供商
|
|
|
|
|
|
if config.provider in NATIVE_ONLY_PROVIDERS:
|
|
|
|
|
|
return cls._create_native_adapter(config)
|
|
|
|
|
|
|
|
|
|
|
|
# 其他提供商使用 LiteLLM
|
|
|
|
|
|
if LiteLLMAdapter.supports_provider(config.provider):
|
|
|
|
|
|
return LiteLLMAdapter(config)
|
|
|
|
|
|
|
|
|
|
|
|
# 不支持的提供商
|
|
|
|
|
|
raise ValueError(f"不支持的LLM提供商: {config.provider}")
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
|
def _create_native_adapter(cls, config: LLMConfig) -> BaseLLMAdapter:
|
|
|
|
|
|
"""创建原生适配器(仅用于 API 格式特殊的提供商)"""
|
|
|
|
|
|
native_adapter_map = {
|
2025-11-26 21:11:12 +08:00
|
|
|
|
LLMProvider.BAIDU: BaiduAdapter,
|
|
|
|
|
|
LLMProvider.MINIMAX: MinimaxAdapter,
|
|
|
|
|
|
LLMProvider.DOUBAO: DoubaoAdapter,
|
|
|
|
|
|
}
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
|
|
|
|
|
adapter_class = native_adapter_map.get(config.provider)
|
2025-11-26 21:11:12 +08:00
|
|
|
|
if not adapter_class:
|
2025-11-28 16:41:39 +08:00
|
|
|
|
raise ValueError(f"不支持的原生适配器提供商: {config.provider}")
|
|
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
return adapter_class(config)
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
|
def _get_cache_key(cls, config: LLMConfig) -> str:
|
|
|
|
|
|
"""生成缓存键"""
|
|
|
|
|
|
api_key_prefix = config.api_key[:8] if config.api_key else "no-key"
|
|
|
|
|
|
return f"{config.provider.value}:{config.model}:{api_key_prefix}"
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
|
def clear_cache(cls) -> None:
|
|
|
|
|
|
"""清除缓存"""
|
|
|
|
|
|
cls._adapters.clear()
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
|
def get_supported_providers(cls) -> List[LLMProvider]:
|
|
|
|
|
|
"""获取支持的提供商列表"""
|
|
|
|
|
|
return list(LLMProvider)
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
|
def get_default_model(cls, provider: LLMProvider) -> str:
|
|
|
|
|
|
"""获取提供商的默认模型"""
|
|
|
|
|
|
return DEFAULT_MODELS.get(provider, "gpt-4o-mini")
|
2025-11-28 16:41:39 +08:00
|
|
|
|
|
2025-11-26 21:11:12 +08:00
|
|
|
|
@classmethod
|
|
|
|
|
|
def get_available_models(cls, provider: LLMProvider) -> List[str]:
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"""获取提供商的可用模型列表 (2025年最新)"""
|
2025-11-26 21:11:12 +08:00
|
|
|
|
models = {
|
|
|
|
|
|
LLMProvider.GEMINI: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"gemini-3-pro",
|
|
|
|
|
|
"gemini-3.0-deep-think",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
"gemini-2.5-flash",
|
|
|
|
|
|
"gemini-2.5-pro",
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"gemini-2.5-flash-lite",
|
|
|
|
|
|
"gemini-2.5-flash-live-api",
|
|
|
|
|
|
"veo-3.1",
|
|
|
|
|
|
"veo-3.1-fast",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.OPENAI: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"gpt-5",
|
|
|
|
|
|
"gpt-5.1",
|
|
|
|
|
|
"gpt-5.1-instant",
|
|
|
|
|
|
"gpt-5.1-codex-max",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
"gpt-4o",
|
|
|
|
|
|
"gpt-4o-mini",
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"gpt-4.5",
|
|
|
|
|
|
"o4-mini",
|
|
|
|
|
|
"o3",
|
|
|
|
|
|
"o3-mini",
|
|
|
|
|
|
"gpt-oss-120b",
|
|
|
|
|
|
"gpt-oss-20b",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.CLAUDE: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"claude-opus-4.5",
|
|
|
|
|
|
"claude-sonnet-4.5",
|
|
|
|
|
|
"claude-haiku-4.5",
|
|
|
|
|
|
"claude-sonnet-4",
|
|
|
|
|
|
"claude-opus-4",
|
|
|
|
|
|
"claude-3.7-sonnet",
|
|
|
|
|
|
"claude-3.5-sonnet",
|
|
|
|
|
|
"claude-3.5-haiku",
|
|
|
|
|
|
"claude-3-opus",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.QWEN: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"qwen3-max-instruct",
|
|
|
|
|
|
"qwen3-235b-a22b",
|
|
|
|
|
|
"qwen3-turbo",
|
|
|
|
|
|
"qwen3-32b",
|
|
|
|
|
|
"qwen3-4b",
|
|
|
|
|
|
"qwen3-embedding-8b",
|
|
|
|
|
|
"qwen-image",
|
|
|
|
|
|
"qwen-vl",
|
|
|
|
|
|
"qwen-audio",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.DEEPSEEK: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"deepseek-v3.1-terminus",
|
|
|
|
|
|
"deepseek-r1-70b",
|
|
|
|
|
|
"deepseek-r1-zero",
|
|
|
|
|
|
"deepseek-v3.2-exp",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
"deepseek-chat",
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"deepseek-reasoner",
|
|
|
|
|
|
"deepseek-ocr",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.ZHIPU: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"glm-4.6",
|
|
|
|
|
|
"glm-4.6-reap-218b",
|
|
|
|
|
|
"glm-4.5",
|
|
|
|
|
|
"glm-4.5v",
|
|
|
|
|
|
"glm-4.5-air-106b",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
"glm-4-flash",
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"glm-4v-flash",
|
|
|
|
|
|
"glm-4.1v-thinking",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.MOONSHOT: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"kimi-k2",
|
|
|
|
|
|
"kimi-k2-thinking",
|
|
|
|
|
|
"kimi-k2-instruct-0905",
|
|
|
|
|
|
"kimi-k1.5",
|
|
|
|
|
|
"kimi-vl",
|
|
|
|
|
|
"kimi-dev-72b",
|
|
|
|
|
|
"kimi-researcher",
|
|
|
|
|
|
"kimi-linear",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.BAIDU: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"ernie-4.5",
|
|
|
|
|
|
"ernie-4.5-21b-a3b-thinking",
|
|
|
|
|
|
"ernie-4.0-8k",
|
|
|
|
|
|
"ernie-3.5-8k",
|
|
|
|
|
|
"ernie-vl",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.MINIMAX: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"minimax-m2",
|
|
|
|
|
|
"minimax-01-text",
|
|
|
|
|
|
"minimax-01-vl",
|
|
|
|
|
|
"minimax-m1",
|
|
|
|
|
|
"speech-2.6",
|
|
|
|
|
|
"hailuo-02",
|
|
|
|
|
|
"music-1.5",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.DOUBAO: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"doubao-1.6-pro",
|
|
|
|
|
|
"doubao-1.5-pro",
|
|
|
|
|
|
"doubao-seed-code",
|
|
|
|
|
|
"doubao-seed-1.6",
|
|
|
|
|
|
"doubao-vision-language",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
LLMProvider.OLLAMA: [
|
feat(llm): enhance LLM connection testing with improved error handling and adapter instantiation
- Bypass LLMFactory cache during connection tests to ensure fresh API calls with latest configuration
- Directly instantiate native adapters (Baidu, Minimax, Doubao) and LiteLLM adapter based on provider type
- Add comprehensive error handling in LiteLLM adapter with specific exception catching for authentication, rate limiting, and connection errors
- Implement user-friendly error messages for common failure scenarios (invalid API key, authentication failure, timeout, connection issues)
- Add response validation to detect and report empty API responses
- Disable LiteLLM internal caching to guarantee actual API calls during testing
- Update available models list with 2025 latest models across all providers (Gemini, OpenAI, Claude, Qwen, DeepSeek, etc.)
- Improve error message clarity and debugging information in config endpoint
2025-11-28 16:53:01 +08:00
|
|
|
|
"llama3.3-70b",
|
|
|
|
|
|
"qwen3-8b",
|
|
|
|
|
|
"gemma3-27b",
|
|
|
|
|
|
"dolphin-3.0-llama3.1-8b",
|
|
|
|
|
|
"cogito-v1",
|
|
|
|
|
|
"deepseek-r1",
|
|
|
|
|
|
"gpt-oss-120b",
|
|
|
|
|
|
"llama3.1-405b",
|
|
|
|
|
|
"mistral-nemo",
|
|
|
|
|
|
"phi-3",
|
2025-11-26 21:11:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
}
|
|
|
|
|
|
return models.get(provider, [])
|