From e40fc66f9830f8f4341feeafa00eb227a940b20a Mon Sep 17 00:00:00 2001 From: geekan Date: Mon, 18 Mar 2024 11:39:30 +0800 Subject: [PATCH] add with_model to BaseLLM --- metagpt/provider/base_llm.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/metagpt/provider/base_llm.py b/metagpt/provider/base_llm.py index 70de4e10d..71308930a 100644 --- a/metagpt/provider/base_llm.py +++ b/metagpt/provider/base_llm.py @@ -39,7 +39,7 @@ class BaseLLM(ABC): # OpenAI / Azure / Others aclient: Optional[Union[AsyncOpenAI]] = None cost_manager: Optional[CostManager] = None - model: Optional[str] = None + model: Optional[str] = None # deprecated pricing_plan: Optional[str] = None @abstractmethod @@ -231,3 +231,8 @@ class BaseLLM(ABC): def messages_to_dict(self, messages): """objects to [{"role": "user", "content": msg}] etc.""" return [i.to_dict() for i in messages] + + def with_model(self, model: str): + """Set model and return self. For example, `with_model("gpt-3.5-turbo")`.""" + self.config.model = model + return self