Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,34 @@ from typing import Optional, Generator
|
|
| 12 |
import numpy as np
|
| 13 |
import faiss
|
| 14 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
import edge_tts
|
| 16 |
from groq import Groq
|
| 17 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 12 |
import numpy as np
|
| 13 |
import faiss
|
| 14 |
import gradio as gr
|
| 15 |
+
|
| 16 |
+
# ── Patch gradio_client bool-schema bug ───────────────────────────────────
|
| 17 |
+
import gradio_client.utils as _gcu
|
| 18 |
+
|
| 19 |
+
def _patched_get_type(schema):
|
| 20 |
+
if not isinstance(schema, dict):
|
| 21 |
+
return "Any"
|
| 22 |
+
if "const" in schema:
|
| 23 |
+
return "Any"
|
| 24 |
+
return _gcu.__class__ # unreachable, replaced below
|
| 25 |
+
|
| 26 |
+
_orig_inner = _gcu._json_schema_to_python_type
|
| 27 |
+
|
| 28 |
+
def _safe_inner(schema, defs=None):
|
| 29 |
+
if not isinstance(schema, dict):
|
| 30 |
+
return "Any"
|
| 31 |
+
# guard additionalProperties being a bool
|
| 32 |
+
if schema.get("additionalProperties") is True or schema.get("additionalProperties") is False:
|
| 33 |
+
schema = dict(schema)
|
| 34 |
+
del schema["additionalProperties"]
|
| 35 |
+
try:
|
| 36 |
+
return _orig_inner(schema, defs)
|
| 37 |
+
except TypeError:
|
| 38 |
+
return "Any"
|
| 39 |
+
|
| 40 |
+
_gcu._json_schema_to_python_type = _safe_inner
|
| 41 |
+
_gcu.json_schema_to_python_type = lambda schema: _safe_inner(schema, schema.get("$defs") if isinstance(schema, dict) else None)
|
| 42 |
+
# ──────────────────────────────────────────────────────────────────────────
|
| 43 |
import edge_tts
|
| 44 |
from groq import Groq
|
| 45 |
from sentence_transformers import SentenceTransformer
|