This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow more subclassing of self-chat world #3955
Merged
+36
−18
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6652c29
Generalize seed utterances logic
EricMichaelSmith 27f8a92
Update seed utterance logic
EricMichaelSmith b1860dd
Modularize logic
EricMichaelSmith bd67ea5
Merge branch 'master' into generalize-self-chat-seed-utterances
EricMichaelSmith 4c252bc
Reset agents method
EricMichaelSmith b3f034e
Streamline seed utterance logic
EricMichaelSmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,13 +132,7 @@ def make_agent_action(utterance: str, agent: Agent) -> Dict[str, Any]: | |
|
||
def parley(self): | ||
if self.episode_done(): | ||
self.turn_cnt = 0 | ||
self.episode_cnt += 1 | ||
self.contexts = None | ||
self.seed_utterances = None | ||
agents = self.get_agents() | ||
for a in agents: | ||
a.reset() | ||
self._end_episode() | ||
|
||
if self.turn_cnt == 0: | ||
self.acts = [None, None] | ||
|
@@ -160,7 +154,7 @@ def parley(self): | |
self.agents[i].observe(validate(context)) | ||
# clear contexts so they are only added once per episode | ||
self.contexts = None | ||
elif self.seed_utterances: | ||
elif self.seed_utterances and self._use_seed_utterances(): | ||
# pop the next two seed messages (there may be less or more than 2 total) | ||
utts = self.seed_utterances[:2] | ||
self.seed_utterances = self.seed_utterances[2:] | ||
|
@@ -186,3 +180,24 @@ def parley(self): | |
|
||
self.update_counters() | ||
self.turn_cnt += 1 | ||
|
||
def _end_episode(self): | ||
""" | ||
Apply logic to end the episode. | ||
""" | ||
self.turn_cnt = 0 | ||
self.episode_cnt += 1 | ||
self.contexts = None | ||
self.seed_utterances = None | ||
agents = self.get_agents() | ||
for a in agents: | ||
a.reset() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should wrap this into self.reset? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've created a |
||
|
||
def _use_seed_utterances(self) -> bool: | ||
""" | ||
Logic to determine whether we should employ seed utterances. | ||
|
||
Defaults to always using seed utterances if they exist, but this can be | ||
overridden. | ||
""" | ||
return True |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a slight preference toward integrating this logic closer with the above:
Maybe by putting the
self._use_seed_utterances
check inside ofself._get_seed_utt_acts
so there's a single source of truth (if self.seed_utterances
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point - changed