Skip to content

Commit 397b1f6

Browse files
committed
add quickly load model config
1 parent b6ce0fb commit 397b1f6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

easyagent/model/litellm_model.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Suppress Pydantic serialization warnings from litellm
88
warnings.filterwarnings("ignore", message="Pydantic serializer warnings")
99

10-
from easyagent.config.base import is_debug
10+
from easyagent.config.base import ModelConfig, is_debug
1111
from easyagent.debug.log import Color, Logger
1212
from easyagent.model.base import BaseLLM
1313
from easyagent.model.schema import LLMResponse, ToolCall
@@ -17,8 +17,17 @@
1717

1818
class LiteLLMModel(BaseLLM):
1919
def __init__(self, model: str, **kwargs):
20-
self._model = model
21-
self._kwargs = kwargs
20+
model_cfg = self._load_model_config(model)
21+
self._model = model_cfg.pop("model")
22+
self._kwargs = {**model_cfg, **kwargs}
23+
24+
@staticmethod
25+
def _load_model_config(model: str) -> dict[str, Any]:
26+
try:
27+
return ModelConfig.load().get_model(model)
28+
except (FileNotFoundError, KeyError):
29+
# config 不存在或模型未配置,直接使用原始模型名
30+
return {"model": model}
2231

2332
async def call(
2433
self,

0 commit comments

Comments
 (0)