Skip to content

Commit

Permalink
修复:
Browse files Browse the repository at this point in the history
- history_len=0 时会带入1条不完整的历史消息,导致LLM错误
- 当对话轮数 达到history_len时,传入的历史消息为空
  • Loading branch information
liunux4odoo committed Oct 19, 2023
1 parent 9b83adc commit 928dea7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def readme():

setuptools.setup(
name='streamlit-chatbox',
version='1.1.9',
version='1.1.10',
author='liunux',
author_email='[email protected]',
description='A chat box and some helpful tools used to build chatbot app with streamlit',
Expand Down
10 changes: 5 additions & 5 deletions streamlit_chatbox/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def default_filter(msg, index=None):
"content": "\n\n".join(content),
}

def default_stop(history):
def default_stop(r):
if isinstance(history_len, int):
user_count = len([x for x in history if x["role"] == "user"])
user_count = len([x for x in r if x["role"] == "user"])
return user_count >= history_len
else:
return False
Expand All @@ -131,17 +131,17 @@ def default_stop(history):
result = []
args_len = len(inspect.signature(filter).parameters)
history = self.other_history(chat_name)

for i, msg in enumerate(history[-1::-1]):
if stop(result):
break
if args_len == 1:
filtered = filter(msg)
else:
filtered = filter(msg, i)
if filtered is not None:
result.insert(0, filtered)

if stop(history):
break

return result

def export2md(
Expand Down

0 comments on commit 928dea7

Please sign in to comment.