Fix new line bug in chat mode for agents (#23267)

This commit is contained in:
Sylvain Gugger 2023-05-10 11:13:42 -04:00 committed by GitHub
parent f93509b114
commit 42017d82ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -264,9 +264,7 @@ class Agent:
""" """
prompt = self.format_prompt(task, chat_mode=True) prompt = self.format_prompt(task, chat_mode=True)
result = self.generate_one(prompt, stop=["Human:", "====="]) result = self.generate_one(prompt, stop=["Human:", "====="])
self.chat_history = prompt + result self.chat_history = prompt + result.strip() + "\n"
if not self.chat_history.endswith("\n"):
self.chat_history += "\n"
explanation, code = clean_code_for_chat(result) explanation, code = clean_code_for_chat(result)
print(f"==Explanation from the agent==\n{explanation}") print(f"==Explanation from the agent==\n{explanation}")