Newshot

Vercel Sandbox Python SDK 1.0 现已发布

AI summary

Vercel Sandbox Python SDK 达到 1.0 版本,其公开 API 已稳定,并与 TypeScript SDK 实现功能对齐。你可以用它从 Python 应用中在隔离沙箱内运行 AI 生成的代码、测试变更和分析数据集。该 SDK 包含用于自动清理沙箱的上下文管理器,以及基于 AnyIO 的异步支持(兼容 asyncio 和 Trio)。

Translation(model translation, not the source's own text)
题图
题图

Vercel Sandbox Python SDK 已发布 1.0 版本,其公共 API 已稳定,并与 TypeScript SDK 功能对齐。你可以用它从 Python 应用中在隔离沙箱内运行 AI 生成的代码、测试改动以及分析数据集。

该 SDK 包含用于自动清理沙箱的上下文管理器,以及基于 AnyIO 的异步支持,适用于 asyncio 和 Trio。对于同步代码,请使用 vercel.sandbox.sync。

使用 uv add 'vercel-sandbox>=1.0' 安装,并配置身份验证。


        import asyncio
from vercel import sandboxfrom vercel.sandbox import GitSource
async def main():    async with sandbox.create_sandbox(        source=GitSource(            url="https://github.com/your-org/your-repo.git",            revision="your-pr-branch",        )    ) as box:        await box.run_command(            "uv",            ["run", "pytest", "-q"],            check=True,        )
asyncio.run(main())
      

从 Git 分支运行测试,随后自动清理沙箱。

如果你是从 0.x 升级,请查阅 1.0 发布说明以了解破坏性变更,包括命令输入和输出改为使用 bytes。

更多信息请参阅 Python SDK 文档。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by Vercel Blog
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗