Update app.py
Browse files
app.py
CHANGED
|
@@ -73,6 +73,16 @@ def prediksi_terjemahan(message, history):
|
|
| 73 |
if isinstance(interaksi, dict):
|
| 74 |
role = interaksi.get("role")
|
| 75 |
content = interaksi.get("content")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
if role and content:
|
| 77 |
percakapan.append({"role": role, "content": str(content)})
|
| 78 |
elif isinstance(interaksi, (list, tuple)) and len(interaksi) == 2:
|
|
|
|
| 73 |
if isinstance(interaksi, dict):
|
| 74 |
role = interaksi.get("role")
|
| 75 |
content = interaksi.get("content")
|
| 76 |
+
|
| 77 |
+
# --- BERIKUT ADALAH PENAMBAHAN MODUL PEMBERSIH UNTUK GRADIO 6.0 ---
|
| 78 |
+
if isinstance(content, list):
|
| 79 |
+
teks_murni = ""
|
| 80 |
+
for item in content:
|
| 81 |
+
if isinstance(item, dict) and "text" in item:
|
| 82 |
+
teks_murni += item["text"]
|
| 83 |
+
content = teks_murni
|
| 84 |
+
# ------------------------------------------------------------------
|
| 85 |
+
|
| 86 |
if role and content:
|
| 87 |
percakapan.append({"role": role, "content": str(content)})
|
| 88 |
elif isinstance(interaksi, (list, tuple)) and len(interaksi) == 2:
|