Skip to content

Commit

Permalink
Fix new line bug in chat mode for agents (#23267)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgugger committed May 10, 2023
1 parent 9dd6209 commit bcf9100
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/transformers/tools/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ def chat(self, task, *, return_code=False, remote=False, **kwargs):
"""
prompt = self.format_prompt(task, chat_mode=True)
result = self.generate_one(prompt, stop=["Human:", "====="])
self.chat_history = prompt + result
if not self.chat_history.endswith("\n"):
self.chat_history += "\n"
self.chat_history = prompt + result.strip() + "\n"
explanation, code = clean_code_for_chat(result)

print(f"==Explanation from the agent==\n{explanation}")
Expand Down

0 comments on commit bcf9100

Please sign in to comment.