Spaces:
Running on Zero
Running on Zero
Place audio after text in chat messages
Browse files
app.py
CHANGED
|
@@ -93,14 +93,20 @@ def _resolve_media_source(path: str) -> str:
|
|
| 93 |
|
| 94 |
|
| 95 |
def _user_content(text: str, files: list[str]) -> list[dict]:
|
| 96 |
-
"""Build a user message content list from text and uploaded file paths.
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
for path in files:
|
| 99 |
kind = _classify_file(path)
|
| 100 |
-
if kind:
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
def process_history(history: list[dict]) -> list[dict]:
|
|
|
|
| 93 |
|
| 94 |
|
| 95 |
def _user_content(text: str, files: list[str]) -> list[dict]:
|
| 96 |
+
"""Build a user message content list from text and uploaded file paths.
|
| 97 |
+
|
| 98 |
+
Media placement follows the model card's guidance: image and video go before
|
| 99 |
+
the text, audio goes after it.
|
| 100 |
+
"""
|
| 101 |
+
before: list[dict] = []
|
| 102 |
+
after: list[dict] = []
|
| 103 |
for path in files:
|
| 104 |
kind = _classify_file(path)
|
| 105 |
+
if kind == "audio":
|
| 106 |
+
after.append({"type": kind, "url": _resolve_media_source(path)})
|
| 107 |
+
elif kind:
|
| 108 |
+
before.append({"type": kind, "url": _resolve_media_source(path)})
|
| 109 |
+
return [*before, {"type": "text", "text": text}, *after]
|
| 110 |
|
| 111 |
|
| 112 |
def process_history(history: list[dict]) -> list[dict]:
|