Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,26 +63,26 @@ def generate(message, history):
|
|
| 63 |
|
| 64 |
# Convert Gradio history
|
| 65 |
if history:
|
| 66 |
-
|
| 67 |
-
|
| 68 |
|
| 69 |
-
|
| 70 |
|
| 71 |
# Gradio 6 sometimes stores content as a list
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
"role": role,
|
| 87 |
"content": content,
|
| 88 |
}
|
|
|
|
| 63 |
|
| 64 |
# Convert Gradio history
|
| 65 |
if history:
|
| 66 |
+
for msg in history:
|
| 67 |
+
role = msg.get("role")
|
| 68 |
|
| 69 |
+
content = msg.get("content", "")
|
| 70 |
|
| 71 |
# Gradio 6 sometimes stores content as a list
|
| 72 |
+
if isinstance(content, list):
|
| 73 |
+
text = ""
|
| 74 |
|
| 75 |
+
for part in content:
|
| 76 |
+
if isinstance(part, dict):
|
| 77 |
+
if part.get("type") == "text":
|
| 78 |
+
text += part.get("text", "")
|
| 79 |
+
elif isinstance(part, str):
|
| 80 |
+
text += part
|
| 81 |
|
| 82 |
+
content = text
|
| 83 |
|
| 84 |
+
messages.append(
|
| 85 |
+
{
|
| 86 |
"role": role,
|
| 87 |
"content": content,
|
| 88 |
}
|