DocsGPT/application/llm/llm_creator.py

22 lines
681 B
Python
Raw Normal View History

2023-09-29 00:09:01 +00:00
from application.llm.openai import OpenAILLM, AzureOpenAILLM
from application.llm.sagemaker import SagemakerAPILLM
from application.llm.huggingface import HuggingFaceLLM
2023-09-30 19:38:48 +00:00
from application.llm.llama_cpp import LlamaCpp
2023-09-29 00:09:01 +00:00
class LLMCreator:
llms = {
'openai': OpenAILLM,
'azure_openai': AzureOpenAILLM,
'sagemaker': SagemakerAPILLM,
2023-09-30 19:38:48 +00:00
'huggingface': HuggingFaceLLM,
'llama.cpp': LlamaCpp
2023-09-29 00:09:01 +00:00
}
@classmethod
def create_llm(cls, type, *args, **kwargs):
llm_class = cls.llms.get(type.lower())
if not llm_class:
raise ValueError(f"No LLM class found for type {type}")
return llm_class(*args, **kwargs)