Update app.py
Browse files
app.py
CHANGED
@@ -126,19 +126,13 @@ class ConversationBot:
|
|
126 |
f"Current Memory: {self.agent.memory.buffer}")
|
127 |
return state, state
|
128 |
|
129 |
-
def run_image(self
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
else:
|
134 |
-
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'
|
135 |
-
AI_prompt = "Received. "
|
136 |
self.agent.memory.buffer = self.agent.memory.buffer + Human_prompt + 'AI: ' + AI_prompt
|
137 |
-
|
138 |
-
|
139 |
-
f"Current Memory: {self.agent.memory.buffer}")
|
140 |
-
return state, state, f'{txt} {image_filename} '
|
141 |
-
|
142 |
def init_agent(self, openai_api_key, lang):
|
143 |
self.memory.clear()
|
144 |
if lang=='English':
|
@@ -191,7 +185,7 @@ with gr.Blocks(css="#chatbot {overflow:auto; height:500px;}") as demo:
|
|
191 |
with gr.Column(scale=0.10, min_width=0):
|
192 |
clear = gr.Button("🔄Clear️")
|
193 |
with gr.Column(scale=0.10, min_width=0):
|
194 |
-
btn = gr.
|
195 |
|
196 |
gr.Examples(
|
197 |
examples=["Generate a figure of a cat running in the garden",
|
@@ -216,6 +210,7 @@ with gr.Blocks(css="#chatbot {overflow:auto; height:500px;}") as demo:
|
|
216 |
txt.submit(bot.run_text, [txt, state], [chatbot, state])
|
217 |
txt.submit(lambda: "", None, txt)
|
218 |
run.click(bot.run_text, [txt, state], [chatbot, state])
|
|
|
219 |
run.click(lambda: "", None, txt)
|
220 |
clear.click(bot.memory.clear)
|
221 |
clear.click(lambda: [], None, chatbot)
|
|
|
126 |
f"Current Memory: {self.agent.memory.buffer}")
|
127 |
return state, state
|
128 |
|
129 |
+
def run_image(self):
|
130 |
+
|
131 |
+
Human_prompt = f'\nHuman: 提供一张名为 123的图片。它的描述是: 一只猫和一只狗。 这些信息帮助你理解这个图像,但是你应该使用工具来完成下面的任务,而不是直接从我的描述中想象。 如果你明白了, 说 \"收到\". \n'
|
132 |
+
AI_prompt = "收到。 "
|
|
|
|
|
|
|
133 |
self.agent.memory.buffer = self.agent.memory.buffer + Human_prompt + 'AI: ' + AI_prompt
|
134 |
+
print(f"Current Memory: {self.agent.memory.buffer}")
|
135 |
+
|
|
|
|
|
|
|
136 |
def init_agent(self, openai_api_key, lang):
|
137 |
self.memory.clear()
|
138 |
if lang=='English':
|
|
|
185 |
with gr.Column(scale=0.10, min_width=0):
|
186 |
clear = gr.Button("🔄Clear️")
|
187 |
with gr.Column(scale=0.10, min_width=0):
|
188 |
+
btn = gr.Button("🖼️Upload")
|
189 |
|
190 |
gr.Examples(
|
191 |
examples=["Generate a figure of a cat running in the garden",
|
|
|
210 |
txt.submit(bot.run_text, [txt, state], [chatbot, state])
|
211 |
txt.submit(lambda: "", None, txt)
|
212 |
run.click(bot.run_text, [txt, state], [chatbot, state])
|
213 |
+
btn.click(bot.run_image, [txt, state], [chatbot, state])
|
214 |
run.click(lambda: "", None, txt)
|
215 |
clear.click(bot.memory.clear)
|
216 |
clear.click(lambda: [], None, chatbot)
|