Skip to content

Commit

Permalink
refactor: cli_input to handle both single and multi line
Browse files Browse the repository at this point in the history
  • Loading branch information
teocns committed Mar 31, 2024
1 parent cc6291f commit d348a00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion interpreter/terminal_interface/terminal_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def terminal_interface(interpreter, message):
try:
if interactive:
### This is the primary input for Open Interpreter.
message = cli_input("> ").strip() if interpreter.multi_line else input("> ").strip()

try:
# This lets users hit the up arrow key for past messages
readline.add_history(message)
except:
# If the user doesn't have readline (may be the case on windows), that's fine
pass
message = cli_input("> ", interpreter.multi_line).strip()

except KeyboardInterrupt:
# Exit gracefully
Expand Down
4 changes: 3 additions & 1 deletion interpreter/terminal_interface/utils/cli_input.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
def cli_input(prompt: str = "") -> str:
def cli_input(prompt: str = "", multi_line=False) -> str:
if not multi_line:
return input(prompt)
start_marker = "```"
end_marker = "```"
message = input(prompt)
Expand Down

0 comments on commit d348a00

Please sign in to comment.