refactor(llm): simplify model name formatting logic in LiteLLMAdapter

- Remove redundant check for CUSTOM_BASE_URL_PROVIDERS
- Consolidate model name prefix logic into single code path
- Move prefix retrieval after model name validation
- Improve code clarity by eliminating unnecessary conditional branches
- Maintain backward compatibility with existing model name formats
This commit is contained in:
lintsinghua 2025-12-09 21:13:14 +08:00
parent 14b7c8cccc
commit 4f0e8a2982
1 changed files with 3 additions and 7 deletions

View File

@ -61,16 +61,12 @@ class LiteLLMAdapter(BaseLLMAdapter):
provider = self.config.provider provider = self.config.provider
model = self.config.model model = self.config.model
# 对于使用 OpenAI 兼容模式的提供商,直接使用模型名
if provider in self.CUSTOM_BASE_URL_PROVIDERS:
return model
# 对于原生支持的提供商,添加前缀
prefix = self.PROVIDER_PREFIX_MAP.get(provider, "openai")
# 检查模型名是否已经包含前缀 # 检查模型名是否已经包含前缀
if "/" in model: if "/" in model:
return model return model
# 获取 provider 前缀
prefix = self.PROVIDER_PREFIX_MAP.get(provider, "openai")
return f"{prefix}/{model}" return f"{prefix}/{model}"