Spaces:
Sleeping
Sleeping
meirk-brd
commited on
Commit
·
0acfa35
1
Parent(s):
2c4cae4
small fix
Browse files
tool.py
CHANGED
|
@@ -68,7 +68,14 @@ class BrightDataScraperTool(Tool):
|
|
| 68 |
|
| 69 |
def _coerce_url_input(self, raw) -> Tuple[Optional[str], Optional[str]]:
|
| 70 |
if isinstance(raw, str):
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
if isinstance(raw, dict):
|
| 74 |
file_path = raw.get("path") or raw.get("name")
|
|
@@ -82,3 +89,12 @@ class BrightDataScraperTool(Tool):
|
|
| 82 |
return f"https://{orig_name}", None
|
| 83 |
|
| 84 |
return None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
def _coerce_url_input(self, raw) -> Tuple[Optional[str], Optional[str]]:
|
| 70 |
if isinstance(raw, str):
|
| 71 |
+
if raw.startswith("{") and "path" in raw:
|
| 72 |
+
parsed = self._parse_file_dict_string(raw)
|
| 73 |
+
if parsed:
|
| 74 |
+
raw = parsed
|
| 75 |
+
else:
|
| 76 |
+
return raw, None
|
| 77 |
+
else:
|
| 78 |
+
return raw, None
|
| 79 |
|
| 80 |
if isinstance(raw, dict):
|
| 81 |
file_path = raw.get("path") or raw.get("name")
|
|
|
|
| 89 |
return f"https://{orig_name}", None
|
| 90 |
|
| 91 |
return None, None
|
| 92 |
+
|
| 93 |
+
def _parse_file_dict_string(self, value: str) -> Optional[dict]:
|
| 94 |
+
import ast
|
| 95 |
+
|
| 96 |
+
try:
|
| 97 |
+
parsed = ast.literal_eval(value)
|
| 98 |
+
return parsed if isinstance(parsed, dict) else None
|
| 99 |
+
except (ValueError, SyntaxError):
|
| 100 |
+
return None
|