MetaGPT/metagpt/llm.py

20 lines
521 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
"""
2024-01-11 20:51:27 +08:00
from typing import Optional
2023-06-30 17:10:48 +08:00
2024-01-11 20:51:27 +08:00
from metagpt.configs.llm_config import LLMConfig
2024-01-10 13:56:02 +08:00
from metagpt.context import CONTEXT
2023-12-26 17:54:52 +08:00
from metagpt.provider.base_llm import BaseLLM
2023-06-30 17:10:48 +08:00
2023-11-29 09:52:26 +08:00
2024-01-11 20:51:27 +08:00
def LLM(llm_config: Optional[LLMConfig] = None) -> BaseLLM:
2024-01-04 21:16:23 +08:00
"""get the default llm provider if name is None"""
2024-01-11 20:51:27 +08:00
if llm_config is not None:
CONTEXT.llm_with_cost_manager_from_llm_config(llm_config)
return CONTEXT.llm()