From 565712a7c64201f7d7a29583dffffa724ef2532a Mon Sep 17 00:00:00 2001 From: imotai Date: Mon, 9 Oct 2023 12:07:56 +0800 Subject: [PATCH 1/4] fix: catch the iterm_image exception --- chat/src/og_terminal/terminal_chat.py | 31 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/chat/src/og_terminal/terminal_chat.py b/chat/src/og_terminal/terminal_chat.py index 743aedd..5ad1c2a 100644 --- a/chat/src/og_terminal/terminal_chat.py +++ b/chat/src/og_terminal/terminal_chat.py @@ -39,8 +39,6 @@ from .utils import parse_file_path from .markdown import CodeBlock import clipboard -from PIL import Image -from term_image.image import AutoImage Markdown.elements["fence"] = CodeBlock Markdown.elements["code_block"] = CodeBlock @@ -351,16 +349,25 @@ def handle_final_answer(segments, respond, values): def render_image(images, sdk, image_dir, console): - image_set = set(images) - for image in image_set: - try: - sdk.download_file(image, image_dir) - fullpath = "%s/%s" % (image_dir, image) - pil_image = Image.open(fullpath) - auto_image = AutoImage(image=pil_image, width=int(pil_image.size[0] / 15)) - print(f"{auto_image:1.1#}") - except Exception as ex: - pass + try: + from PIL import Image + from term_image.image import AutoImage + + image_set = set(images) + for image in image_set: + try: + sdk.download_file(image, image_dir) + fullpath = "%s/%s" % (image_dir, image) + pil_image = Image.open(fullpath) + auto_image = AutoImage( + image=pil_image, width=int(pil_image.size[0] / 15) + ) + print(f"{auto_image:1.1#}") + return True + except Exception as ex: + return False + except Exception as ex: + return False def run_chat( From d70f8fd89a15b161a86697e62ae5ffaa9b4fe97d Mon Sep 17 00:00:00 2001 From: imotai Date: Mon, 9 Oct 2023 12:51:29 +0800 Subject: [PATCH 2/4] fix:set folder permission to 777 --- docker/start_all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/start_all.sh b/docker/start_all.sh index 64c5fe8..1acff58 100755 --- a/docker/start_all.sh +++ b/docker/start_all.sh @@ -13,7 +13,7 @@ then fi ROOT_DIR=$1 -chown octogen:octogen -R ${ROOT_DIR} +chown -R 777 ${ROOT_DIR} cat < /bin/start_service.sh if [ "$2" -eq 1 ] then From 4ac1f5dda60d7eefaa0d43c36d6b6e5f574e0915 Mon Sep 17 00:00:00 2001 From: imotai Date: Mon, 9 Oct 2023 15:09:37 +0800 Subject: [PATCH 3/4] fix: only change the new created dir permission to octogen --- docker/start_all.sh | 8 +++++++- up/src/og_up/up.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docker/start_all.sh b/docker/start_all.sh index 1acff58..f51bd01 100755 --- a/docker/start_all.sh +++ b/docker/start_all.sh @@ -13,7 +13,13 @@ then fi ROOT_DIR=$1 -chown -R 777 ${ROOT_DIR} +mkdir -p ${ROOT_DIR}/kernel/ws +mkdir -p ${ROOT_DIR}/agent/db +mkdir -p ${ROOT_DIR}/kernel/config +chown -R octogen:octogen ${ROOT_DIR}/kernel/ws +chown -R octogen:octogen ${ROOT_DIR}/kernel/config +chown -R octogen:octogen ${ROOT_DIR}/agent/db + cat < /bin/start_service.sh if [ "$2" -eq 1 ] then diff --git a/up/src/og_up/up.py b/up/src/og_up/up.py index 4d0286c..9b26add 100644 --- a/up/src/og_up/up.py +++ b/up/src/og_up/up.py @@ -296,7 +296,7 @@ def generate_agent_common(fd, rpc_key): fd.write(f"admin_key={rpc_key}\n") fd.write("max_file_size=202400000\n") fd.write("max_iterations=8\n") - fd.write("db_path=/app/agent/octogen.db\n") + fd.write("db_path=/app/agent/db/octogen.db\n") def generate_agent_azure_openai( From 3443c5a1c9f6a0040acc14447569328dd1e825e4 Mon Sep 17 00:00:00 2001 From: imotai Date: Mon, 9 Oct 2023 15:16:34 +0800 Subject: [PATCH 4/4] fix: update the prompt for openai --- agent/src/og_agent/openai_agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/src/og_agent/openai_agent.py b/agent/src/og_agent/openai_agent.py index c4beb61..2014bdb 100644 --- a/agent/src/og_agent/openai_agent.py +++ b/agent/src/og_agent/openai_agent.py @@ -54,7 +54,7 @@ }, { "name": "python", - "description": "this function must not be used", + "description": "You must not call this function", "parameters": { "type": "object", "properties": {