psaegert's picture
Upload 201 files
2c34d2f
return "", prompt_file
if input.__contains__("show config"):
prompt_file.show_config()
return "config shown", prompt_file
# multi turn/single turn commands
if input.__contains__("multi-turn"):
# start context
if input.__contains__("start"):
if config['multi_turn'] == 'off':
prompt_file.start_multi_turn()
return "multi turn mode on", prompt_file
return "multi turn mode on", prompt_file
# stop context
if input.__contains__("stop"):
prompt_file.stop_multi_turn()
return "multi turn mode off", prompt_file
# context file commands
if input.__contains__("context"):
if input.__contains__("default"):
prompt_file.default_context()
return "stopped context", prompt_file
# show context <n>
if input.__contains__("show"):
print('\n')
with open(prompt_file.file_name, 'r') as f:
lines = f.readlines()
lines = lines[6:] # skip headers
line_numbers = 0
if len(input.split()) > 3:
line_numbers = int(input.split()[3])
if line_numbers != 0:
for line in lines[-line_numbers:]:
print('\n# '+line, end='')
else:
print('\n# '.join(lines))
return "context shown", prompt_file
# edit context
if input.__contains__("view"):
# open the prompt file in text editor
if config['shell'] != 'powershell':
os.system('open {}'.format(prompt_file.file_path))
else:
os.system('start {}'.format(prompt_file.file_path))
return "context shown", prompt_file
# save context <filename>
if input.__contains__("save"):
# save the current prompt file to