add context and config2

This commit is contained in:
geekan 2024-01-04 21:16:23 +08:00
parent 42bb40a0f6
commit e5d11a046c
76 changed files with 922 additions and 495 deletions

View file

@ -8,17 +8,10 @@
from typing import Optional
from metagpt.config import CONFIG, LLMProviderEnum
from metagpt.context import context
from metagpt.provider.base_llm import BaseLLM
from metagpt.provider.human_provider import HumanProvider
from metagpt.provider.llm_provider_registry import LLM_REGISTRY
_ = HumanProvider() # Avoid pre-commit error
def LLM(provider: Optional[LLMProviderEnum] = None) -> BaseLLM:
"""get the default llm provider"""
if provider is None:
provider = CONFIG.get_default_llm_provider_enum()
return LLM_REGISTRY.get_provider(provider)
def LLM(name: Optional[str] = None) -> BaseLLM:
"""get the default llm provider if name is None"""
return context.llm(name)