Browse Source

Merge pull request #465 from B1gM8c/master

支持自定义openai_api_base
zhayujie 3 years ago
parent
commit
1dc39af423
3 changed files with 3 additions and 0 deletions
  1. 1 0
      bot/chatgpt/chat_gpt_bot.py
  2. 1 0
      bot/openai/open_ai_bot.py
  3. 1 0
      config-template.json

+ 1 - 0
bot/chatgpt/chat_gpt_bot.py

@@ -16,6 +16,7 @@ else:
 class ChatGPTBot(Bot):
     def __init__(self):
         openai.api_key = conf().get('open_ai_api_key')
+        openai.api_base = conf().get('open_ai_api_base')
         proxy = conf().get('proxy')
         if proxy:
             openai.proxy = proxy

+ 1 - 0
bot/openai/open_ai_bot.py

@@ -12,6 +12,7 @@ user_session = dict()
 class OpenAIBot(Bot):
     def __init__(self):
         openai.api_key = conf().get('open_ai_api_key')
+        openai.api_base = conf().get('open_ai_api_base')
 
 
     def reply(self, query, context=None):

+ 1 - 0
config-template.json

@@ -1,5 +1,6 @@
 {
   "open_ai_api_key": "YOUR API KEY",
+  "open_ai_api_base":"",
   "proxy": "",
   "single_chat_prefix": ["bot", "@bot"],
   "single_chat_reply_prefix": "[bot] ",