返回提交历史
Modified
g4f/mcp/pa_downloader.py
+5
-5
XFEstudio/gpt4free
Improve download pa providers
fbaf539d
代码差异
1 个文件
+5
-5
@@ -107,7 +107,7 @@ def _list_repo_files(repo: str, ref: str, timeout: float) -> List[str]:
107
107
if not isinstance(entry, dict):
108
108
continue
109
109
name = entry.get("name", "")
110
if name.endswith(".py") and entry.get("type") == "file":
110
if (name.endswith(".py") or name.endswith(".wasm")) and entry.get("type") == "file":
111
111
files.append(name)
112
112
return files
113
113
@@ -170,7 +170,7 @@ def run_pa_download(
170
170
return written
171
171
172
172
for name in names:
173
if not name.endswith(".py"):
173
if not name.endswith(".py") and not name.endswith(".wasm"):
174
174
continue
175
175
dest = target / name
176
176
if dest.exists() and not force:
@@ -229,8 +229,8 @@ def run_pa_remove(filename: str, directory: Optional[str] = None) -> bool:
229
229
except ValueError:
230
230
print(f"Error: {filename} escapes the workspace directory.")
231
231
return False
232
if not candidate.name.endswith(".py"):
233
print(f"Error: {filename} is not a .py file.")
232
if not candidate.name.endswith(".pa.py"):
233
print(f"Error: {filename} is not a .pa.py file.")
234
234
return False
235
235
if not candidate.exists():
236
236
print(f"Error: {filename} not found in {target}")
@@ -288,7 +288,7 @@ def auto_download_pa_providers(
288
288
289
289
debug.log(f"pa-providers: auto-downloading from {repo}@{ref}")
290
290
try:
291
written = run_pa_download(repo=repo, ref=ref, force=force, timeout=timeout)
291
written = run_pa_download(repo=repo, ref=ref, force=True, timeout=timeout)
292
292
except Exception as e:
293
293
# run_pa_download already swallows most errors, but be defensive.
294
294
debug.error("pa-providers: auto-download failed:", e)