bot_factory.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. """
  2. channel factory
  3. """
  4. from common import const
  5. def create_bot(bot_type):
  6. """
  7. create a bot_type instance
  8. :param bot_type: bot type code
  9. :return: bot instance
  10. """
  11. if bot_type == const.BAIDU:
  12. # 替换Baidu Unit为Baidu文心千帆对话接口
  13. # from bot.baidu.baidu_unit_bot import BaiduUnitBot
  14. # return BaiduUnitBot()
  15. from bot.baidu.baidu_wenxin import BaiduWenxinBot
  16. return BaiduWenxinBot()
  17. elif bot_type == const.CHATGPT:
  18. # ChatGPT 网页端web接口
  19. from bot.chatgpt.chat_gpt_bot import ChatGPTBot
  20. return ChatGPTBot()
  21. elif bot_type == const.OPEN_AI:
  22. # OpenAI 官方对话模型API
  23. from bot.openai.open_ai_bot import OpenAIBot
  24. return OpenAIBot()
  25. elif bot_type == const.CHATGPTONAZURE:
  26. # Azure chatgpt service https://azure.microsoft.com/en-in/products/cognitive-services/openai-service/
  27. from bot.chatgpt.chat_gpt_bot import AzureChatGPTBot
  28. return AzureChatGPTBot()
  29. elif bot_type == const.XUNFEI:
  30. from bot.xunfei.xunfei_spark_bot import XunFeiBot
  31. return XunFeiBot()
  32. elif bot_type == const.LINKAI:
  33. from bot.linkai.link_ai_bot import LinkAIBot
  34. return LinkAIBot()
  35. elif bot_type == const.CLAUDEAI:
  36. from bot.claude.claude_ai_bot import ClaudeAIBot
  37. return ClaudeAIBot()
  38. elif bot_type == const.CLAUDEAPI:
  39. from bot.claudeapi.claude_api_bot import ClaudeAPIBot
  40. return ClaudeAPIBot()
  41. elif bot_type == const.QWEN:
  42. from bot.ali.ali_qwen_bot import AliQwenBot
  43. return AliQwenBot()
  44. elif bot_type == const.QWEN_DASHSCOPE:
  45. from bot.dashscope.dashscope_bot import DashscopeBot
  46. return DashscopeBot()
  47. elif bot_type == const.GEMINI:
  48. from bot.gemini.google_gemini_bot import GoogleGeminiBot
  49. return GoogleGeminiBot()
  50. elif bot_type == const.DIFY:
  51. from bot.dify.dify_bot import DifyBot
  52. return DifyBot()
  53. elif bot_type == const.ZHIPU_AI:
  54. from bot.zhipuai.zhipuai_bot import ZHIPUAIBot
  55. return ZHIPUAIBot()
  56. elif bot_type == const.COZE:
  57. from bot.bytedance.bytedance_coze_bot import ByteDanceCozeBot
  58. return ByteDanceCozeBot()
  59. elif bot_type == const.MOONSHOT:
  60. from bot.moonshot.moonshot_bot import MoonshotBot
  61. return MoonshotBot()
  62. elif bot_type == const.MiniMax:
  63. from bot.minimax.minimax_bot import MinimaxBot
  64. return MinimaxBot()
  65. raise RuntimeError