MetaGPT/metagpt/llm.py

21 lines
657 B
Python
Raw Normal View History

2023-06-30 17:10:48 +08:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/11 14:45
@Author : alexanderwu
@File : llm.py
"""
2023-11-27 17:43:20 +08:00
from metagpt.config import CONFIG
2023-12-14 20:34:04 +08:00
from metagpt.provider.base_gpt_api import BaseGPTAPI
2023-11-29 09:52:26 +08:00
from metagpt.provider.human_provider import HumanProvider
2023-12-19 17:55:34 +08:00
from metagpt.provider.llm_provider_registry import LLMProviderRegistry
2023-06-30 17:10:48 +08:00
2023-11-29 09:52:55 +08:00
_ = HumanProvider() # Avoid pre-commit error
2023-11-29 09:52:26 +08:00
2023-06-30 17:10:48 +08:00
def LLM() -> BaseGPTAPI:
2023-11-28 18:16:50 +08:00
"""initialize different LLM instance according to the key field existence"""
2023-11-27 17:43:20 +08:00
# TODO a little trick, can use registry to initialize LLM instance further
2023-12-19 17:55:34 +08:00
return LLMProviderRegistry.get_provider(CONFIG.get_default_llm_provider_enum())