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:
parent
14b7c8cccc
commit
4f0e8a2982
|
|
@ -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}"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue