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

Commit

Permalink
generation allow new line (#4954)
Browse files Browse the repository at this point in the history
  • Loading branch information
klshuster authored Feb 13, 2023
1 parent a8e84a1 commit 8633e04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion projects/bb3/agents/opt_api_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,12 @@ def add_cmdline_args(
help='if a generation is returned with a newline character, set True to take last newline. '
'set False to take first new line.',
)
parser.add_argument(
'--generation-allow-newline',
type='bool',
default=False,
help='if a generation is returned with a newline character, set True to return all generated tokens.',
)
parser.add_argument(
'--memory-decision-use-memories',
type='bool',
Expand Down Expand Up @@ -713,7 +719,7 @@ def get_gen_results(self, observations: List[Message], **gen_params):
if not APIUtils.is_request_failed_response(r):
r['choices'][0]['text'] = r['choices'][0]['text'].strip("\n")

if any(
if not self.opt.get('generation_allow_newline') and any(
'\n' in res['choices'][0]['text']
for res in results
if not APIUtils.is_request_failed_response(res)
Expand Down
14 changes: 14 additions & 0 deletions projects/bb3/tests/opt_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,20 @@
"grm_partner_prefix": "Partner",
"orm_partner_prefix": "Partner",
"brm_partner_prefix": "Partner",
"sdm_generation_allow_newline": False,
"mdm_generation_allow_newline": False,
"sgm_generation_allow_newline": False,
"mgm_generation_allow_newline": False,
"mkm_generation_allow_newline": False,
"ckm_generation_allow_newline": False,
"skm_generation_allow_newline": False,
"srm_generation_allow_newline": False,
"crm_generation_allow_newline": False,
"mrm_generation_allow_newline": False,
"vrm_generation_allow_newline": False,
"grm_generation_allow_newline": False,
"orm_generation_allow_newline": False,
"brm_generation_allow_newline": False,
"self_prefix": "Person 2",
"self_memory_prefix": "Person 2's Persona",
"partner_prefix": "Person 1",
Expand Down

0 comments on commit 8633e04

Please sign in to comment.