From 70dec6254d4296be539583ff4c18cf151d0f0615 Mon Sep 17 00:00:00 2001 From: Steve Wang Date: Sat, 27 Jan 2024 16:40:26 +0800 Subject: [PATCH 1/3] Fix render_past_conversation --- .../conversation_navigator.py | 6 ++--- .../render_past_conversation.py | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/interpreter/terminal_interface/conversation_navigator.py b/interpreter/terminal_interface/conversation_navigator.py index e0c0b69c7b..af4a01baea 100644 --- a/interpreter/terminal_interface/conversation_navigator.py +++ b/interpreter/terminal_interface/conversation_navigator.py @@ -15,9 +15,9 @@ def conversation_navigator(interpreter): - print( - "This feature is not working as of 0.2.0 (The New Computer Update). Please consider submitting a PR to repair it with the new streaming format." - ) + # print( + # "This feature is not working as of 0.2.0 (The New Computer Update). Please consider submitting a PR to repair it with the new streaming format." + # ) import time time.sleep(5) diff --git a/interpreter/terminal_interface/render_past_conversation.py b/interpreter/terminal_interface/render_past_conversation.py index 8867d6fe6b..49940b7f99 100644 --- a/interpreter/terminal_interface/render_past_conversation.py +++ b/interpreter/terminal_interface/render_past_conversation.py @@ -16,26 +16,27 @@ def render_past_conversation(messages): render_cursor = False ran_code_block = False + print(messages) for chunk in messages: # Only addition to the terminal interface: if chunk["role"] == "user": if active_block: active_block.end() active_block = None - print(">", chunk["message"]) + print(">", chunk["content"]) continue # Message - if "message" in chunk: + if chunk["type"] == "message": if active_block is None: active_block = MessageBlock() if active_block.type != "message": active_block.end() active_block = MessageBlock() - active_block.message += chunk["message"] + active_block.message += chunk["content"] # Code - if "code" in chunk or "language" in chunk: + if chunk["type"] == "code": if active_block is None: active_block = CodeBlock() if active_block.type != "code" or ran_code_block: @@ -46,18 +47,18 @@ def render_past_conversation(messages): ran_code_block = False render_cursor = True - if "language" in chunk: - active_block.language = chunk["language"] - if "code" in chunk: - active_block.code += chunk["code"] - if "active_line" in chunk: - active_block.active_line = chunk["active_line"] + if "format" in chunk: + active_block.language = chunk["format"] + if "content" in chunk: + active_block.code += chunk["content"] + if "active_line" in chunk: + active_block.active_line = chunk["active_line"] - # Output - if "output" in chunk: + # Console + if chunk["type"] == "console": ran_code_block = True render_cursor = False - active_block.output += "\n" + chunk["output"] + active_block.output += "\n" + chunk["content"] active_block.output = active_block.output.strip() # <- Aesthetic choice if active_block: From 32850b4b8a7f7d92a9ccbb8f9c14dd5e2b876eef Mon Sep 17 00:00:00 2001 From: Steve Wang Date: Sat, 27 Jan 2024 18:14:24 +0800 Subject: [PATCH 2/3] Clean. --- interpreter/terminal_interface/conversation_navigator.py | 3 --- interpreter/terminal_interface/render_past_conversation.py | 1 - 2 files changed, 4 deletions(-) diff --git a/interpreter/terminal_interface/conversation_navigator.py b/interpreter/terminal_interface/conversation_navigator.py index af4a01baea..173a670ec2 100644 --- a/interpreter/terminal_interface/conversation_navigator.py +++ b/interpreter/terminal_interface/conversation_navigator.py @@ -15,9 +15,6 @@ def conversation_navigator(interpreter): - # print( - # "This feature is not working as of 0.2.0 (The New Computer Update). Please consider submitting a PR to repair it with the new streaming format." - # ) import time time.sleep(5) diff --git a/interpreter/terminal_interface/render_past_conversation.py b/interpreter/terminal_interface/render_past_conversation.py index 49940b7f99..b603df0c33 100644 --- a/interpreter/terminal_interface/render_past_conversation.py +++ b/interpreter/terminal_interface/render_past_conversation.py @@ -16,7 +16,6 @@ def render_past_conversation(messages): render_cursor = False ran_code_block = False - print(messages) for chunk in messages: # Only addition to the terminal interface: if chunk["role"] == "user": From 95f6847daf8a0039e4be372b79ba21cd0a399029 Mon Sep 17 00:00:00 2001 From: Steve Wang Date: Sun, 28 Jan 2024 02:17:07 +0800 Subject: [PATCH 3/3] Avoid showing an error when user quits the conversation navigator --- interpreter/terminal_interface/conversation_navigator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interpreter/terminal_interface/conversation_navigator.py b/interpreter/terminal_interface/conversation_navigator.py index 173a670ec2..55eb43cff4 100644 --- a/interpreter/terminal_interface/conversation_navigator.py +++ b/interpreter/terminal_interface/conversation_navigator.py @@ -64,6 +64,10 @@ def conversation_navigator(interpreter): ] answers = inquirer.prompt(questions) + # User chose to exit + if not answers: + return + # If the user selected to open the folder, do so and return if answers["name"] == "> Open folder": open_folder(conversations_dir)