Parcourir la source

azure api add api-version:https://learn.microsoft.com/zh-cn/azure/ai-services/openai/reference

zyqcn@live.com il y a 2 ans
Parent
commit
74a253f521
3 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 1 0
      README.md
  2. 1 1
      bot/chatgpt/chat_gpt_bot.py
  3. 1 0
      config.py

+ 1 - 0
README.md

@@ -123,6 +123,7 @@ pip3 install azure-cognitiveservices-speech
   "group_speech_recognition": false,                          # 是否开启群组语音识别
   "group_speech_recognition": false,                          # 是否开启群组语音识别
   "use_azure_chatgpt": false,                                 # 是否使用Azure ChatGPT service代替openai ChatGPT service. 当设置为true时需要设置 open_ai_api_base,如 https://xxx.openai.azure.com/
   "use_azure_chatgpt": false,                                 # 是否使用Azure ChatGPT service代替openai ChatGPT service. 当设置为true时需要设置 open_ai_api_base,如 https://xxx.openai.azure.com/
   "azure_deployment_id": "",                                  # 采用Azure ChatGPT时,模型部署名称
   "azure_deployment_id": "",                                  # 采用Azure ChatGPT时,模型部署名称
+  "azure_api_version": "",                                    # 采用Azure ChatGPT时,API版本
   "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。",  # 人格描述
   "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。",  # 人格描述
   # 订阅消息,公众号和企业微信channel中请填写,当被订阅时会自动回复,可使用特殊占位符。目前支持的占位符有{trigger_prefix},在程序中它会自动替换成bot的触发词。
   # 订阅消息,公众号和企业微信channel中请填写,当被订阅时会自动回复,可使用特殊占位符。目前支持的占位符有{trigger_prefix},在程序中它会自动替换成bot的触发词。
   "subscribe_msg": "感谢您的关注!\n这里是ChatGPT,可以自由对话。\n支持语音对话。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持角色扮演和文字冒险等丰富插件。\n输入{trigger_prefix}#help 查看详细指令。"
   "subscribe_msg": "感谢您的关注!\n这里是ChatGPT,可以自由对话。\n支持语音对话。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持角色扮演和文字冒险等丰富插件。\n输入{trigger_prefix}#help 查看详细指令。"

+ 1 - 1
bot/chatgpt/chat_gpt_bot.py

@@ -166,7 +166,7 @@ class AzureChatGPTBot(ChatGPTBot):
     def __init__(self):
     def __init__(self):
         super().__init__()
         super().__init__()
         openai.api_type = "azure"
         openai.api_type = "azure"
-        openai.api_version = "2023-03-15-preview"
+        openai.api_version = conf().get("azure_api_version", "2023-06-01-preview")
         self.args["deployment_id"] = conf().get("azure_deployment_id")
         self.args["deployment_id"] = conf().get("azure_deployment_id")
 
 
     def create_img(self, query, retry_count=0, api_key=None):
     def create_img(self, query, retry_count=0, api_key=None):

+ 1 - 0
config.py

@@ -19,6 +19,7 @@ available_setting = {
     "model": "gpt-3.5-turbo",
     "model": "gpt-3.5-turbo",
     "use_azure_chatgpt": False,  # 是否使用azure的chatgpt
     "use_azure_chatgpt": False,  # 是否使用azure的chatgpt
     "azure_deployment_id": "",  # azure 模型部署名称
     "azure_deployment_id": "",  # azure 模型部署名称
+    "azure_api_version": "",  # azure api版本
     # Bot触发配置
     # Bot触发配置
     "single_chat_prefix": ["bot", "@bot"],  # 私聊时文本需要包含该前缀才能触发机器人回复
     "single_chat_prefix": ["bot", "@bot"],  # 私聊时文本需要包含该前缀才能触发机器人回复
     "single_chat_reply_prefix": "[bot] ",  # 私聊时自动回复的前缀,用于区分真人
     "single_chat_reply_prefix": "[bot] ",  # 私聊时自动回复的前缀,用于区分真人