🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
refine code
geekanb338dfca648a
diff --git a/metagpt/context.py b/metagpt/context.pyindex 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] = Nonedef 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@propertydef 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