SuperAPI AI 工具集

python-executor

编程与开发

查看项目

更新于 10-15 22:37

技能介绍

python-executor 是 inference.sh 提供的沙箱化 Python 代码执行技能,通过其 CLI 工具 infsh 调用,适合在隔离环境中运行 Python 脚本并返回输出文件。

用途:在安全沙箱中执行 Python 代码,支持数据分析、网页抓取、图像处理、视频生成、3D 模型处理和 API 调用等任务。

主要能力:环境为 Python 3.10 且仅 CPU,无 GPU/ML 库;默认 8GB 内存,可用 high_memory 变体获得 16GB;超时 1 至 300 秒,默认 30 秒;预装 requests、httpx、aiohttp、beautifulsoup4、lxml、selenium、playwright、scrapy、numpy、pandas、scipy、matplotlib、seaborn、plotly、pillow、opencv-python-headless、scikit-image、imageio、moviepy、av、ffmpeg-python、pydub、trimesh、open3d、numpy-stl、meshio、pyvista、svgwrite、cairosvg、reportlab、pypdf2 等 100 多个库。写入 outputs/ 目录的文件会被自动检测并随响应返回。

使用方式:需先安装 inference.sh CLI 并执行 infsh login。基本调用为 infsh app run infsh/python-executor --input '{"code": "..."}'�输入字段包括 code、timeout、capture_output、working_dir。大内存场景使用 infsh app run infsh/python-executor@high_memory --input input.json。注意为非交互式环境,绘图应使用 plt.savefig() 而非 plt.show()。

适用场景:网页抓取、数据分析与可视化、图像编辑、带文字叠加的视频生成、3D 模型加载转换导出、API 集成、PDF 报告生成和脚本自动化。

限制:仅 CPU 环境,不含 GPU/ML 库;代码在隔离子进程中运行;不支持交互式操作;沙箱与网络访问的具体边界、收费标准及配额暂未提供。