-
Notifications
You must be signed in to change notification settings - Fork 115
/
bot.py
30 lines (23 loc) · 904 Bytes
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import litellm
from common.context import Context
from config import conf
from common.singleton import singleton
from common.reply import Reply
@singleton
class Bot:
def __init__(self):
use_azure_chatgpt = conf().get("use_azure_chatgpt", False)
model = conf().get("model", "gpt-3.5-turbo")
if use_azure_chatgpt:
from bot.azure_chatgpt import AzureChatGPTBot
self.bot = AzureChatGPTBot()
elif model in litellm.open_ai_chat_completion_models:
from bot.chatgpt import ChatGPTBot
self.bot = ChatGPTBot()
else:
# see litellm supported models here:
# https://litellm.readthedocs.io/en/latest/supported/
from bot.litellm import LiteLLMChatGPTBot
self.bot = LiteLLMChatGPTBot()
def reply(self, context: Context) -> Reply:
return self.bot.reply(context)