mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-16 09:26:07 +00:00
fix(session.py): 错误的undo()方法逻辑
This commit is contained in:
@@ -228,16 +228,15 @@ class Session:
|
|||||||
def undo(self) -> str:
|
def undo(self) -> str:
|
||||||
self.last_interact_timestamp = int(time.time())
|
self.last_interact_timestamp = int(time.time())
|
||||||
|
|
||||||
# 删除上一回合
|
# 删除最后两个消息
|
||||||
if self.prompt[-1]['role'] != 'user':
|
if len(self.prompt) < 2:
|
||||||
res = self.prompt[-1]['content']
|
raise Exception('之前无对话,无法撤销')
|
||||||
self.prompt.remove(self.prompt[-2])
|
|
||||||
else:
|
question = self.prompt[-2]['content']
|
||||||
res = self.prompt[-2]['content']
|
self.prompt = self.prompt[:-2]
|
||||||
self.prompt.remove(self.prompt[-1])
|
|
||||||
|
|
||||||
# 返回上一回合的问题
|
# 返回上一回合的问题
|
||||||
return res
|
return question
|
||||||
|
|
||||||
# 构建对话体
|
# 构建对话体
|
||||||
def cut_out(self, msg: str, max_tokens: int) -> list:
|
def cut_out(self, msg: str, max_tokens: int) -> list:
|
||||||
|
|||||||
Reference in New Issue
Block a user