Spaces:
Runtime error
Runtime error
Commit
·
d39610d
1
Parent(s):
e9b7220
Refactor URL generation in format_history_as_messages to use consistent variable naming for file paths, improving code clarity and maintainability.
Browse files- app/app.py +3 -4
app/app.py
CHANGED
|
@@ -76,12 +76,11 @@ def format_history_as_messages(history: list):
|
|
| 76 |
current_message_content = []
|
| 77 |
|
| 78 |
if isinstance(content, tuple): # Handle file paths
|
| 79 |
-
for
|
| 80 |
if space_host := os.getenv("SPACE_HOST"):
|
| 81 |
-
url = f"https://{space_host}/gradio_api/file%3D{
|
| 82 |
else:
|
| 83 |
-
url = _convert_path_to_data_uri(
|
| 84 |
-
print(url)
|
| 85 |
current_message_content.append(
|
| 86 |
{"type": "image_url", "image_url": {"url": url}}
|
| 87 |
)
|
|
|
|
| 76 |
current_message_content = []
|
| 77 |
|
| 78 |
if isinstance(content, tuple): # Handle file paths
|
| 79 |
+
for temp_path in content:
|
| 80 |
if space_host := os.getenv("SPACE_HOST"):
|
| 81 |
+
url = f"https://{space_host}/gradio_api/file%3D{temp_path}"
|
| 82 |
else:
|
| 83 |
+
url = _convert_path_to_data_uri(temp_path)
|
|
|
|
| 84 |
current_message_content.append(
|
| 85 |
{"type": "image_url", "image_url": {"url": url}}
|
| 86 |
)
|