You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bridge.py 787B

123456789101112131415161718192021222324
  1. from bot import bot_factory
  2. from voice import voice_factory
  3. from config import conf
  4. from common import const
  5. class Bridge(object):
  6. def __init__(self):
  7. pass
  8. def fetch_reply_content(self, query, context):
  9. bot_type = const.CHATGPT
  10. model_type = conf().get("model")
  11. if model_type in ["gpt-3.5-turbo", "gpt-4", "gpt-4-32k"]:
  12. bot_type = const.CHATGPT
  13. elif model_type in ["text-davinci-003"]:
  14. bot_type = const.OPEN_AI
  15. return bot_factory.create_bot(bot_type).reply(query, context)
  16. def fetch_voice_to_text(self, voiceFile):
  17. return voice_factory.create_voice("openai").voiceToText(voiceFile)
  18. def fetch_text_to_voice(self, text):
  19. return voice_factory.create_voice("baidu").textToVoice(text)