mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-10 21:10:59 +00:00
Merge pull request #522 from RockChinQ/feat-generating-stop-case
[Feat] 新增!continue命令
This commit is contained in:
@@ -26,7 +26,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install --upgrade yiri-mirai openai colorlog func_timeout dulwich Pillow CallingGPT
|
python -m pip install --upgrade yiri-mirai openai colorlog func_timeout dulwich Pillow CallingGPT tiktoken
|
||||||
|
|
||||||
- name: Copy Scripts
|
- name: Copy Scripts
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -159,9 +159,14 @@ class ChatCompletionRequest(RequestBase):
|
|||||||
logging.info("执行函数调用: name={}, arguments={}".format(func_name, arguments))
|
logging.info("执行函数调用: name={}, arguments={}".format(func_name, arguments))
|
||||||
|
|
||||||
# 执行函数调用
|
# 执行函数调用
|
||||||
ret = execute_function(func_name, arguments)
|
ret = ""
|
||||||
|
try:
|
||||||
|
ret = execute_function(func_name, arguments)
|
||||||
|
|
||||||
logging.info("函数执行完成。")
|
logging.info("函数执行完成。")
|
||||||
|
except Exception as e:
|
||||||
|
ret = "error: execute function failed: {}".format(str(e))
|
||||||
|
logging.error("函数执行失败: {}".format(str(e)))
|
||||||
|
|
||||||
self.append_message(
|
self.append_message(
|
||||||
role="function",
|
role="function",
|
||||||
|
|||||||
+10
-8
@@ -194,7 +194,7 @@ class Session:
|
|||||||
|
|
||||||
# 请求回复
|
# 请求回复
|
||||||
# 这个函数是阻塞的
|
# 这个函数是阻塞的
|
||||||
def append(self, text: str) -> str:
|
def append(self, text: str=None) -> str:
|
||||||
"""向session中添加一条消息,返回接口回复"""
|
"""向session中添加一条消息,返回接口回复"""
|
||||||
|
|
||||||
self.last_interact_timestamp = int(time.time())
|
self.last_interact_timestamp = int(time.time())
|
||||||
@@ -270,7 +270,8 @@ class Session:
|
|||||||
# 将此次对话的双方内容加入到prompt中
|
# 将此次对话的双方内容加入到prompt中
|
||||||
# self.prompt.append({'role': 'user', 'content': text})
|
# self.prompt.append({'role': 'user', 'content': text})
|
||||||
# self.prompt.append({'role': 'assistant', 'content': res_ans})
|
# self.prompt.append({'role': 'assistant', 'content': res_ans})
|
||||||
self.prompt.append({'role': 'user', 'content': text})
|
if text:
|
||||||
|
self.prompt.append({'role': 'user', 'content': text})
|
||||||
# 添加pending_msgs
|
# 添加pending_msgs
|
||||||
self.prompt += pending_msgs
|
self.prompt += pending_msgs
|
||||||
|
|
||||||
@@ -331,12 +332,13 @@ class Session:
|
|||||||
result_prompt = self.default_prompt + changable_prompts
|
result_prompt = self.default_prompt + changable_prompts
|
||||||
|
|
||||||
# 添加当前问题
|
# 添加当前问题
|
||||||
result_prompt.append(
|
if msg:
|
||||||
{
|
result_prompt.append(
|
||||||
'role': 'user',
|
{
|
||||||
'content': msg
|
'role': 'user',
|
||||||
}
|
'content': msg
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
|
||||||
logging.debug("cut_out: {}".format(json.dumps(result_prompt, ensure_ascii=False, indent=4)))
|
logging.debug("cut_out: {}".format(json.dumps(result_prompt, ensure_ascii=False, indent=4)))
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import pkg.utils.updater as updater
|
|||||||
description="插件管理",
|
description="插件管理",
|
||||||
usage="!plugin\n!plugin get <插件仓库地址>\n!plugin update\n!plugin del <插件名>\n!plugin on <插件名>\n!plugin off <插件名>",
|
usage="!plugin\n!plugin get <插件仓库地址>\n!plugin update\n!plugin del <插件名>\n!plugin on <插件名>\n!plugin off <插件名>",
|
||||||
aliases=[],
|
aliases=[],
|
||||||
privilege=2
|
privilege=1
|
||||||
)
|
)
|
||||||
class PluginCommand(AbstractCommandNode):
|
class PluginCommand(AbstractCommandNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
from ..aamgr import AbstractCommandNode, Context
|
||||||
|
|
||||||
|
|
||||||
|
@AbstractCommandNode.register(
|
||||||
|
parent=None,
|
||||||
|
name="continue",
|
||||||
|
description="继续未完成的响应",
|
||||||
|
usage="!continue",
|
||||||
|
aliases=[],
|
||||||
|
privilege=1
|
||||||
|
)
|
||||||
|
class ContinueCommand(AbstractCommandNode):
|
||||||
|
@classmethod
|
||||||
|
def process(cls, ctx: Context) -> tuple[bool, list]:
|
||||||
|
import pkg.openai.session
|
||||||
|
import config
|
||||||
|
session_name = ctx.session_name
|
||||||
|
|
||||||
|
reply = []
|
||||||
|
|
||||||
|
session = pkg.openai.session.get_session(session_name)
|
||||||
|
|
||||||
|
text = session.append()
|
||||||
|
|
||||||
|
reply = [text]
|
||||||
|
|
||||||
|
return True, reply
|
||||||
@@ -2,12 +2,13 @@
|
|||||||
"comment": "以下为命令权限,请设置到cmdpriv.json中。关于此功能的说明,请查看:https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E5%91%BD%E4%BB%A4%E6%9D%83%E9%99%90%E6%8E%A7%E5%88%B6",
|
"comment": "以下为命令权限,请设置到cmdpriv.json中。关于此功能的说明,请查看:https://github.com/RockChinQ/QChatGPT/wiki/%E5%8A%9F%E8%83%BD%E4%BD%BF%E7%94%A8#%E5%91%BD%E4%BB%A4%E6%9D%83%E9%99%90%E6%8E%A7%E5%88%B6",
|
||||||
"draw": 1,
|
"draw": 1,
|
||||||
"func": 1,
|
"func": 1,
|
||||||
"plugin": 2,
|
"plugin": 1,
|
||||||
"plugin.get": 2,
|
"plugin.get": 2,
|
||||||
"plugin.update": 2,
|
"plugin.update": 2,
|
||||||
"plugin.del": 2,
|
"plugin.del": 2,
|
||||||
"plugin.off": 2,
|
"plugin.off": 2,
|
||||||
"plugin.on": 2,
|
"plugin.on": 2,
|
||||||
|
"continue": 1,
|
||||||
"default": 1,
|
"default": 1,
|
||||||
"default.set": 2,
|
"default.set": 2,
|
||||||
"del": 1,
|
"del": 1,
|
||||||
|
|||||||
@@ -180,6 +180,7 @@
|
|||||||
!draw <提示语> 进行绘图
|
!draw <提示语> 进行绘图
|
||||||
!version 查看当前版本并检查更新
|
!version 查看当前版本并检查更新
|
||||||
!resend 重新回复上一个问题
|
!resend 重新回复上一个问题
|
||||||
|
!continue 继续响应未完成的回合(通常用于内容函数继续调用)
|
||||||
!plugin 用法请查看插件使用页的`管理`章节
|
!plugin 用法请查看插件使用页的`管理`章节
|
||||||
!default 查看可用的情景预设值
|
!default 查看可用的情景预设值
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user