Spaces:
Runtime error
Runtime error
Commit
·
195ed03
1
Parent(s):
6793b42
Update image URL handling in format_history_as_messages function to support SPACE_HOST environment variable
Browse files- app/app.py +7 -2
app/app.py
CHANGED
|
@@ -77,9 +77,12 @@ def format_history_as_messages(history: list):
|
|
| 77 |
|
| 78 |
if isinstance(content, tuple): # Handle file paths
|
| 79 |
for path in content:
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
current_message_content.append(
|
| 82 |
-
{"type": "image_url", "image_url": {"url":
|
| 83 |
)
|
| 84 |
elif isinstance(content, str): # Handle text
|
| 85 |
current_message_content.append({"type": "text", "text": content})
|
|
@@ -398,3 +401,5 @@ with gr.Blocks(css=css) as demo:
|
|
| 398 |
)
|
| 399 |
|
| 400 |
demo.launch()
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
if isinstance(content, tuple): # Handle file paths
|
| 79 |
for path in content:
|
| 80 |
+
if space_host := os.getenv("SPACE_HOST"):
|
| 81 |
+
url = f"https://{space_host}/gradio_api/file%3D/{path}"
|
| 82 |
+
else:
|
| 83 |
+
url = _convert_path_to_data_uri(path)
|
| 84 |
current_message_content.append(
|
| 85 |
+
{"type": "image_url", "image_url": {"url": url}}
|
| 86 |
)
|
| 87 |
elif isinstance(content, str): # Handle text
|
| 88 |
current_message_content.append({"type": "text", "text": content})
|
|
|
|
| 401 |
)
|
| 402 |
|
| 403 |
demo.launch()
|
| 404 |
+
|
| 405 |
+
# /private/var/folders/9t/msy700h16jz3q35qvg4z1ln40000gn/T/gradio/a5013b9763ad9f2192254540fee226539fbcd1382cbc2317b916aef469bb01b9/Screenshot 2025-01-13 at 08.02.26.png
|