Spaces:
Sleeping
Sleeping
meirk-brd
commited on
Commit
·
0a73403
1
Parent(s):
719bd5b
ignore gradio api temp file
Browse files
tool.py
CHANGED
|
@@ -211,6 +211,8 @@ class BrightDataDatasetTool(Tool):
|
|
| 211 |
return None
|
| 212 |
|
| 213 |
if isinstance(raw, str):
|
|
|
|
|
|
|
| 214 |
if raw.strip().startswith("{") and "orig_name" in raw:
|
| 215 |
parsed = self._parse_file_dict_string(raw)
|
| 216 |
if parsed:
|
|
@@ -233,6 +235,16 @@ class BrightDataDatasetTool(Tool):
|
|
| 233 |
if isinstance(url_value, str):
|
| 234 |
if url_value.startswith(("http://", "https://")):
|
| 235 |
return url_value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
return None
|
| 237 |
|
| 238 |
return None
|
|
|
|
| 211 |
return None
|
| 212 |
|
| 213 |
if isinstance(raw, str):
|
| 214 |
+
if raw.lstrip().startswith("<"):
|
| 215 |
+
return None
|
| 216 |
if raw.strip().startswith("{") and "orig_name" in raw:
|
| 217 |
parsed = self._parse_file_dict_string(raw)
|
| 218 |
if parsed:
|
|
|
|
| 235 |
if isinstance(url_value, str):
|
| 236 |
if url_value.startswith(("http://", "https://")):
|
| 237 |
return url_value
|
| 238 |
+
if url_value.startswith("/gradio_api/file="):
|
| 239 |
+
file_path = url_value.split("=", 1)[-1]
|
| 240 |
+
if os.path.isfile(file_path):
|
| 241 |
+
try:
|
| 242 |
+
with open(file_path, "r", encoding="utf-8", errors="ignore") as fh:
|
| 243 |
+
text = fh.read().strip()
|
| 244 |
+
if text and not text.lstrip().startswith("<"):
|
| 245 |
+
return self._ensure_scheme(text)
|
| 246 |
+
except OSError:
|
| 247 |
+
pass
|
| 248 |
return None
|
| 249 |
|
| 250 |
return None
|