Skip to content

Commit

Permalink
[Feature] Support to remove history for chat script (InternLM#144)
Browse files Browse the repository at this point in the history
* [Feature] Support to remove history for chat script

* fix typo
  • Loading branch information
LZHgrla authored Sep 27, 2023
1 parent 70a8882 commit 22b9dc5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions xtuner/tools/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def get_input():
sentinel = '' # ends when this string is seen
result = None
while result is None:
print('\ndouble enter to end input >>> ', end='')
print(('\ndouble enter to end input (EXIT: exit chat, '
'RESET: reset history) >>> '),
end='')
try:
result = '\n'.join(iter(input, sentinel))
except UnicodeDecodeError:
Expand Down Expand Up @@ -178,8 +180,13 @@ def main():
inputs = ''
while True:
text = get_input()

if text == 'exit':
while text.strip() == 'RESET':
print('Log: History responses have been removed!')
n_turn = 0
inputs = ''
text = get_input()
if text.strip() == 'EXIT':
print('Log: Exit!')
exit(0)
if args.prompt_template is not None:
template = PROMPT_TEMPLATE[args.prompt_template]
Expand Down

0 comments on commit 22b9dc5

Please sign in to comment.