update app.py
Browse files
app.py
CHANGED
|
@@ -40,15 +40,17 @@ class Client:
|
|
| 40 |
|
| 41 |
chatbot += [(self._text_input, None)]
|
| 42 |
|
| 43 |
-
|
| 44 |
-
for image_url in
|
| 45 |
if image_url.startswith('http'):
|
| 46 |
image_url = self._download_media(image_url)
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
if audio_url.startswith('http'):
|
| 50 |
audio_url = self._download_media(audio_url)
|
| 51 |
-
|
|
|
|
| 52 |
|
| 53 |
return chatbot
|
| 54 |
|
|
@@ -73,15 +75,21 @@ class Client:
|
|
| 73 |
self._response = self._client.generate_response(self._text_input, self._task_result_list)
|
| 74 |
chatbot += [(None, self._response)]
|
| 75 |
|
| 76 |
-
|
| 77 |
-
for image_url in
|
|
|
|
|
|
|
| 78 |
if image_url.startswith('http'):
|
| 79 |
image_url = self._download_media(image_url)
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 82 |
if audio_url.startswith('http'):
|
| 83 |
audio_url = self._download_media(audio_url)
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
# self._client.save_context(self._text_input, self._response)
|
| 87 |
|
|
|
|
| 40 |
|
| 41 |
chatbot += [(self._text_input, None)]
|
| 42 |
|
| 43 |
+
self._image_inputs, self._audio_inputs = self._extract_medias(self._text_input)
|
| 44 |
+
for image_url in self._image_inputs:
|
| 45 |
if image_url.startswith('http'):
|
| 46 |
image_url = self._download_media(image_url)
|
| 47 |
+
if os.path.exists(image_url):
|
| 48 |
+
chatbot += [((image_url,), None)]
|
| 49 |
+
for audio_url in self._audio_inputs:
|
| 50 |
if audio_url.startswith('http'):
|
| 51 |
audio_url = self._download_media(audio_url)
|
| 52 |
+
if os.path.exists(audio_url):
|
| 53 |
+
chatbot += [((audio_url,), None)]
|
| 54 |
|
| 55 |
return chatbot
|
| 56 |
|
|
|
|
| 75 |
self._response = self._client.generate_response(self._text_input, self._task_result_list)
|
| 76 |
chatbot += [(None, self._response)]
|
| 77 |
|
| 78 |
+
image_outputs, audio_outputs = self._extract_medias(self._response)
|
| 79 |
+
for image_url in image_outputs:
|
| 80 |
+
if image_url in self._image_inputs:
|
| 81 |
+
continue
|
| 82 |
if image_url.startswith('http'):
|
| 83 |
image_url = self._download_media(image_url)
|
| 84 |
+
if os.path.exists(image_url):
|
| 85 |
+
chatbot += [(None, (image_url,))]
|
| 86 |
+
for audio_url in audio_outputs:
|
| 87 |
+
if audio_url in self._audio_inputs:
|
| 88 |
+
continue
|
| 89 |
if audio_url.startswith('http'):
|
| 90 |
audio_url = self._download_media(audio_url)
|
| 91 |
+
if os.path.exists(audio_url):
|
| 92 |
+
chatbot += [(None, (audio_url,))]
|
| 93 |
|
| 94 |
# self._client.save_context(self._text_input, self._response)
|
| 95 |
|