Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Implement __str__ for History #3510

Merged
merged 1 commit into from
Mar 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion parlai/core/torch_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def update_history(self, obs: Message, temp_history: Optional[str] = None):

self.temp_history = temp_history

def get_history_str(self):
def get_history_str(self) -> Optional[str]:
"""
Return the string version of the history.
"""
Expand Down Expand Up @@ -346,6 +346,9 @@ def _add_person_tokens(self, text, token, add_after_newln=False):
else:
return token + ' ' + text

def __str__(self) -> str:
return self.get_history_str() or ''


class TorchAgent(ABC, Agent):
"""
Expand Down