feat: + LLMType

This commit is contained in:
莘权 马 2023-09-07 11:01:27 +08:00
parent 7cafdc5c5b
commit 832294809b
2 changed files with 25 additions and 3 deletions

View file

@ -4,17 +4,37 @@
@Time : 2023/5/11 14:45
@Author : alexanderwu
@File : llm.py
@Modified By: mashenquan, 2023
"""
from enum import Enum
from metagpt.provider.anthropic_api import Claude2 as Claude
from metagpt.provider.openai_api import OpenAIGPTAPI as LLM
class LLMType(Enum):
OPENAI = "OpenAI"
METAGPT = "MetaGPT"
UNKNOWN = "UNKNOWN"
@classmethod
def get(cls, value):
for member in cls:
if member.value == value:
return member
return cls.UNKNOWN
@property
def UNKNOWN(self):
return LLMType.UNKNOWN
DEFAULT_LLM = LLM()
CLAUDE_LLM = Claude()
async def ai_func(prompt):
"""使用LLM进行QA
QA with LLMs
"""
QA with LLMs
"""
return await DEFAULT_LLM.aask(prompt)

View file

@ -4,9 +4,11 @@
@Time : 2023/5/5 22:59
@Author : alexanderwu
@File : __init__.py
@Modified By: mashenquan, 2023/9/8. Add `MetaGPTLLMAPI`
"""
from metagpt.provider.openai_api import OpenAIGPTAPI
from metagpt.provider.metagpt_llm_api import MetaGPTLLMAPI
__all__ = ["OpenAIGPTAPI"]
__all__ = ["OpenAIGPTAPI", "MetaGPTLLMAPI"]