diff --git a/list.json b/list.json index d3f57c6..a82081f 100644 --- a/list.json +++ b/list.json @@ -862,13 +862,13 @@ }, { "name": "openaichat", - "version": "1.1", + "version": "1.2", "section": "chat", "maintainer": "jiechus", - "size": "4.857 kb", + "size": "5.131 kb", "supported": true, - "des-short": "openaichat", - "des": "openaichat" + "des-short": "openaichat 使用 OpenAI Chat 聊天", + "des": "openaichat 使用 OpenAI Chat 聊天\n基于 text-davinci-003 模型,与 ChatGPT 的效果有些许不同\n代码参考了原先的 ChatGPT 插件" }, { "name": "copy_sticker_set", diff --git a/openaichat/main.py b/openaichat/main.py index 3a8b90e..35f9bec 100644 --- a/openaichat/main.py +++ b/openaichat/main.py @@ -1,5 +1,6 @@ import contextlib import threading +import re from collections import defaultdict @@ -22,7 +23,7 @@ async def get_chat_response(prompt: str) -> str: top_p=1, frequency_penalty=0.0, presence_penalty=0.6, - stop=[" Human:", " AI:"] + stop=["Human: ", "AI: "] ).choices[0].text @@ -54,6 +55,7 @@ def get_template() -> str: def formatted_response(prompt: str, message: str) -> str: if not get_template(): set_template(default_template) + message = re.sub(r'^\s+', r'', message) try: return get_template().format(prompt, message) except Exception: @@ -67,6 +69,7 @@ chat_bot_help = "使用 OpenAI Chat 聊天\n" \ "代码参考了原先的 ChatGPT 插件\n\n" \ "参数:\n\n- 问题:询问 ai\n" \ "- reset:重置聊天话题\n" \ + "- thread:获取已记录的聊天话题\n" \ "- set :设置 OpenAI API Key,获取 API Key: https://beta.openai.com/account/api-keys \n" \ "- del:删除 OpenAI API Key\n" \ "- template {set|get|reset}