🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
Update llm.py
Zhaoyang Yuc9989c069e98
diff --git a/metagpt/llm.py b/metagpt/llm.pyindex 465e419a1..88fe8bd44 100644--- a/metagpt/llm.py+++ b/metagpt/llm.py@@ -10,11 +10,18 @@ from typing import Optionalfrom metagpt.configs.llm_config import LLMConfigfrom metagpt.context import Contextfrom metagpt.provider.base_llm import BaseLLM+from metagpt.utils.cost_manager import CostManager+global cost_manager++if not globals().get("cost_manager"):+ cost_manager = CostManager()def LLM(llm_config: Optional[LLMConfig] = None, context: Context = None) -> BaseLLM:"""get the default llm provider if name is None"""ctx = context or Context()if llm_config is not None:return ctx.llm_with_cost_manager_from_llm_config(llm_config)- return ctx.llm()+ llm = ctx.llm()+ llm.cost_manager = cost_manager+ return llm