From b338dfca648a97d23e1c780458b9e9fca4728215 Mon Sep 17 00:00:00 2001 From: geekan Date: Tue, 9 Jan 2024 17:04:45 +0800 Subject: [PATCH] refine code --- metagpt/context.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/metagpt/context.py b/metagpt/context.py index 495fe9e2f..ba859ed5c 100644 --- a/metagpt/context.py +++ b/metagpt/context.py @@ -45,24 +45,24 @@ class AttrDict(BaseModel): class LLMMixin: """Mixin class for LLM""" - config: Optional[Config] = None - llm_config: Optional[LLMConfig] = None + # _config: Optional[Config] = None + _llm_config: Optional[LLMConfig] = None _llm_instance: Optional[BaseLLM] = None def use_llm(self, name: Optional[str] = None, provider: LLMType = LLMType.OPENAI): """Use a LLM provider""" # 更新LLM配置 - self.llm_config = self.config.get_llm_config(name, provider) + self._llm_config = self._config.get_llm_config(name, provider) # 重置LLM实例 self._llm_instance = None @property def llm(self) -> BaseLLM: """Return the LLM instance""" - if not self.llm_config: + if not self._llm_config: self.use_llm() - if not self._llm_instance and self.llm_config: - self._llm_instance = create_llm_instance(self.llm_config) + if not self._llm_instance and self._llm_config: + self._llm_instance = create_llm_instance(self._llm_config) return self._llm_instance