Python Hello 模板
Fixture:本目录是主仓库的离线测试夹具(
client-sdk/tests/test_templates/使用), 不是发布真源。模板内容、索引与发布以alibaba-agent-sandbox/awesome-templates为准。
基础 Python 开发环境模板。
安装
以下
abx命令由独立cli仓库中的abxCLI 提供(npm install -g @agent-sandbox/cli)。
abx template install ./examples/templates/python-hello --registry-type local
使用
abx create --template python-hello
命名命令(端到端)
容器启动后会自动运行 commands.py,监听端口 9000,提供以下命名命令(用 abx sandbox command list <sandbox-id> 查看):
# 打招呼
abx run <sandbox-id> hello --arg name=Alice
# → Hello, Alice!
# 执行 Python 代码
abx run <sandbox-id> run_script --arg 'code=print(1+1)'
# → 2
SDK 侧等价写法:
from agent_sandbox import Sandbox
sandbox = Sandbox.create(template="python-hello")
result = sandbox.run("hello", name="Alice")
print(result.value) # Hello, Alice!
上传 / 下载
abx upload <sandbox-id> ./local_file.txt /app/remote.txt
abx download <sandbox-id> /app/remote.txt ./local_file.txt
环境
- 基础镜像: Ubuntu 22.04
- Python 3 + pip
- 容器内运行时:
pip install agent-sandbox-server(提供agent_sandbox.server) - 工作目录: /app