Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,7 @@ def chat(message, history, openai_api_key):
|
|
37 |
raise gr.Error("Message is required.")
|
38 |
|
39 |
with lock:
|
40 |
-
|
41 |
|
42 |
try:
|
43 |
if os.environ["OPENAI_API_KEY"] != openai_api_key:
|
@@ -60,15 +60,14 @@ def chat(message, history, openai_api_key):
|
|
60 |
text_values, image_values = extract_content_values(messages)
|
61 |
|
62 |
if len(image_values) > 0:
|
63 |
-
|
64 |
|
65 |
for text_value in list(reversed(text_values)):
|
66 |
-
|
67 |
except Exception as e:
|
68 |
raise gr.Error(e)
|
69 |
|
70 |
-
return f"{
|
71 |
-
#return f"{'<hr>'.join(list(reversed(text_values))[1:])}{images}"
|
72 |
|
73 |
gr.ChatInterface(
|
74 |
fn=chat,
|
|
|
37 |
raise gr.Error("Message is required.")
|
38 |
|
39 |
with lock:
|
40 |
+
result_text, result_image = "", ""
|
41 |
|
42 |
try:
|
43 |
if os.environ["OPENAI_API_KEY"] != openai_api_key:
|
|
|
60 |
text_values, image_values = extract_content_values(messages)
|
61 |
|
62 |
if len(image_values) > 0:
|
63 |
+
result_image = f"[https://platform.openai.com/storage/files/{image_values[0]}](https://platform.openai.com/storage/files/{image_values[0]})<br><br>"
|
64 |
|
65 |
for text_value in list(reversed(text_values)):
|
66 |
+
result_text += f"{text_value}<br><br>"
|
67 |
except Exception as e:
|
68 |
raise gr.Error(e)
|
69 |
|
70 |
+
return f"{result_image}{result_text}"
|
|
|
71 |
|
72 |
gr.ChatInterface(
|
73 |
fn=chat,
|