mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-15 11:02:36 +02:00
Update llm.py
This commit is contained in:
parent
008c5f0f1f
commit
c9989c069e
1 changed files with 8 additions and 1 deletions
|
|
@ -10,11 +10,18 @@ from typing import Optional
|
|||
from metagpt.configs.llm_config import LLMConfig
|
||||
from metagpt.context import Context
|
||||
from 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue