|
@@ -1,11 +1,12 @@
|
|
|
-from bot import bot_factory
|
|
|
|
|
|
|
+from bot.factory import create_bot
|
|
|
from bridge.context import Context
|
|
from bridge.context import Context
|
|
|
from bridge.reply import Reply
|
|
from bridge.reply import Reply
|
|
|
from common import const
|
|
from common import const
|
|
|
from common.log import logger
|
|
from common.log import logger
|
|
|
from common.singleton import singleton
|
|
from common.singleton import singleton
|
|
|
from config import conf
|
|
from config import conf
|
|
|
-from voice import voice_factory
|
|
|
|
|
|
|
+from translate.factory import create_translator
|
|
|
|
|
+from voice.factory import create_voice
|
|
|
|
|
|
|
|
|
|
|
|
|
@singleton
|
|
@singleton
|
|
@@ -15,6 +16,7 @@ class Bridge(object):
|
|
|
"chat": const.CHATGPT,
|
|
"chat": const.CHATGPT,
|
|
|
"voice_to_text": conf().get("voice_to_text", "openai"),
|
|
"voice_to_text": conf().get("voice_to_text", "openai"),
|
|
|
"text_to_voice": conf().get("text_to_voice", "google"),
|
|
"text_to_voice": conf().get("text_to_voice", "google"),
|
|
|
|
|
+ "translate": conf().get("translate", "baidu"),
|
|
|
}
|
|
}
|
|
|
model_type = conf().get("model")
|
|
model_type = conf().get("model")
|
|
|
if model_type in ["text-davinci-003"]:
|
|
if model_type in ["text-davinci-003"]:
|
|
@@ -27,11 +29,13 @@ class Bridge(object):
|
|
|
if self.bots.get(typename) is None:
|
|
if self.bots.get(typename) is None:
|
|
|
logger.info("create bot {} for {}".format(self.btype[typename], typename))
|
|
logger.info("create bot {} for {}".format(self.btype[typename], typename))
|
|
|
if typename == "text_to_voice":
|
|
if typename == "text_to_voice":
|
|
|
- self.bots[typename] = voice_factory.create_voice(self.btype[typename])
|
|
|
|
|
|
|
+ self.bots[typename] = create_voice(self.btype[typename])
|
|
|
elif typename == "voice_to_text":
|
|
elif typename == "voice_to_text":
|
|
|
- self.bots[typename] = voice_factory.create_voice(self.btype[typename])
|
|
|
|
|
|
|
+ self.bots[typename] = create_voice(self.btype[typename])
|
|
|
elif typename == "chat":
|
|
elif typename == "chat":
|
|
|
- self.bots[typename] = bot_factory.create_bot(self.btype[typename])
|
|
|
|
|
|
|
+ self.bots[typename] = create_bot(self.btype[typename])
|
|
|
|
|
+ elif typename == "translate":
|
|
|
|
|
+ self.bots[typename] = create_translator(self.btype[typename])
|
|
|
return self.bots[typename]
|
|
return self.bots[typename]
|
|
|
|
|
|
|
|
def get_bot_type(self, typename):
|
|
def get_bot_type(self, typename):
|