From 48709e5b6a402581bfd2df18a5e79d5e438497e6 Mon Sep 17 00:00:00 2001 From: "Mr.hu" <390131208@qq.com> Date: Sun, 26 Mar 2023 01:52:26 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9Afix=20the=20regular=20expression?= =?UTF-8?q?=20that=20does=20not=20display=20pictures=20on=20the=20front=20?= =?UTF-8?q?end?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- visual_chatgpt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/visual_chatgpt.py b/visual_chatgpt.py index e9614894..07b4585a 100644 --- a/visual_chatgpt.py +++ b/visual_chatgpt.py @@ -1013,7 +1013,7 @@ def run_text(self, text, state): self.agent.memory.buffer = cut_dialogue_history(self.agent.memory.buffer, keep_last_n_words=500) res = self.agent({"input": text}) res['output'] = res['output'].replace("\\", "/") - response = re.sub('(image/\S*png)', lambda m: f'![](/file={m.group(0)})*{m.group(0)}*', res['output']) + response = re.sub('(image/\S*png)', lambda m: f'![](file={m.group(0)})*{m.group(0)}*', res['output']) state = state + [(text, response)] print(f"\nProcessed run_text, Input text: {text}\nCurrent state: {state}\n" f"Current Memory: {self.agent.memory.buffer}") @@ -1036,7 +1036,7 @@ def run_image(self, image, state, txt): Human_prompt = f'\nHuman: provide a figure named {image_filename}. The description is: {description}. This information helps you to understand this image, but you should use tools to finish following tasks, rather than directly imagine from my description. If you understand, say \"Received\". \n' AI_prompt = "Received. " self.agent.memory.buffer = self.agent.memory.buffer + Human_prompt + 'AI: ' + AI_prompt - state = state + [(f"![](/file={image_filename})*{image_filename}*", AI_prompt)] + state = state + [(f"![](file={image_filename})*{image_filename}*", AI_prompt)] print(f"\nProcessed run_image, Input image: {image_filename}\nCurrent state: {state}\n" f"Current Memory: {self.agent.memory.buffer}") return state, state, f'{txt} {image_filename} '