From 05f230cc851e03af7ab2950a4e155744b54e4d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Solbj=C3=B8rg?= <4324290+Notnaton@users.noreply.github.com> Date: Tue, 23 Jan 2024 17:42:55 +0100 Subject: [PATCH 1/3] Move the entry point to start_terminal_interface While talking with @Arrendy going through some code made a change to the entry point Co-Authored-By: Mike Bird <63524998+Arrendy@users.noreply.github.com> --- .../terminal_interface/start_terminal_interface.py | 9 +++++++++ pyproject.toml | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/interpreter/terminal_interface/start_terminal_interface.py b/interpreter/terminal_interface/start_terminal_interface.py index 2ef186eb89..3a9bf7607d 100644 --- a/interpreter/terminal_interface/start_terminal_interface.py +++ b/interpreter/terminal_interface/start_terminal_interface.py @@ -7,6 +7,7 @@ import pkg_resources +from ..core.core import OpenInterpreter from .conversation_navigator import conversation_navigator from .utils.apply_config import apply_config from .utils.check_for_update import check_for_update @@ -16,6 +17,14 @@ from .validate_llm_settings import validate_llm_settings +def main(): + interpreter = OpenInterpreter() + try: + start_terminal_interface(interpreter) + except KeyboardInterrupt as e: + print(e) + + def start_terminal_interface(interpreter): """ Meant to be used from the command line. Parses arguments, starts OI's terminal interface. diff --git a/pyproject.toml b/pyproject.toml index 17eae2512e..4cc5ed73e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,8 +57,8 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] -interpreter = "interpreter.terminal_interface.cli:main" -i = "interpreter.terminal_interface.cli:main" +interpreter = "interpreter.terminal_interface.start_terminal_interface:main" +i = "interpreter.terminal_interface.start_terminal_interface:main" [tool.black] target-version = ['py311'] From c157067d6a9ac861bddca8c869d945b99817fe9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Solbj=C3=B8rg?= <4324290+Notnaton@users.noreply.github.com> Date: Tue, 23 Jan 2024 17:47:06 +0100 Subject: [PATCH 2/3] Formatting, delete old cli.py and move main() to bottom Co-Authored-By: Mike Bird <63524998+Arrendy@users.noreply.github.com> --- interpreter/terminal_interface/cli.py | 11 ----------- .../start_terminal_interface.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 19 deletions(-) delete mode 100644 interpreter/terminal_interface/cli.py diff --git a/interpreter/terminal_interface/cli.py b/interpreter/terminal_interface/cli.py deleted file mode 100644 index f00c065f95..0000000000 --- a/interpreter/terminal_interface/cli.py +++ /dev/null @@ -1,11 +0,0 @@ -# cli.py -from ..core.core import OpenInterpreter -from .start_terminal_interface import start_terminal_interface - - -def main(): - interpreter = OpenInterpreter() - try: - start_terminal_interface(interpreter) - except KeyboardInterrupt: - print("Exited.") diff --git a/interpreter/terminal_interface/start_terminal_interface.py b/interpreter/terminal_interface/start_terminal_interface.py index 3a9bf7607d..b7872e98bf 100644 --- a/interpreter/terminal_interface/start_terminal_interface.py +++ b/interpreter/terminal_interface/start_terminal_interface.py @@ -17,14 +17,6 @@ from .validate_llm_settings import validate_llm_settings -def main(): - interpreter = OpenInterpreter() - try: - start_terminal_interface(interpreter) - except KeyboardInterrupt as e: - print(e) - - def start_terminal_interface(interpreter): """ Meant to be used from the command line. Parses arguments, starts OI's terminal interface. @@ -698,3 +690,11 @@ def start_terminal_interface(interpreter): interpreter.in_terminal_interface = True interpreter.chat() + + +def main(): + interpreter = OpenInterpreter() + try: + start_terminal_interface(interpreter) + except KeyboardInterrupt as e: + print(e) From 2a92ab77578b3d999b9a18d8347a24c25c6e788a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Solbj=C3=B8rg?= <4324290+Notnaton@users.noreply.github.com> Date: Wed, 24 Jan 2024 18:12:53 +0100 Subject: [PATCH 3/3] merge upstream, more error handling --- interpreter/terminal_interface/start_terminal_interface.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/interpreter/terminal_interface/start_terminal_interface.py b/interpreter/terminal_interface/start_terminal_interface.py index b7872e98bf..4d4ea09b84 100644 --- a/interpreter/terminal_interface/start_terminal_interface.py +++ b/interpreter/terminal_interface/start_terminal_interface.py @@ -697,4 +697,8 @@ def main(): try: start_terminal_interface(interpreter) except KeyboardInterrupt as e: - print(e) + print("Interrupted by user:", e) + except Exception as e: + print("An error occurred:", e) + finally: + print("Closing the program.")