本页还没有译文
本页 10 段还没译成한국어,下面显示的是英文原文。ModalSandbox integration
还没翻译译自英文(docs.langchain.com)本页 10 段都还没译
Modal provides serverless container infrastructure with GPU support. See the Modal docs for signup, authentication, and platform details.
Installation
pipuv
pip install langchain-modaluv add langchain-modalCreate a sandbox backend
In Python, you create the sandbox using the provider SDK, then wrap it with the deepagents backend.
import modal
from langchain_modal import ModalSandbox
app = modal.App.lookup("your-app")
modal_sandbox = modal.Sandbox.create(app=app)
backend = ModalSandbox(sandbox=modal_sandbox)
result = backend.execute("echo hello")
print(result.output)Use with Deep Agents
import modal
from langchain_anthropic import ChatAnthropic
from deepagents import create_deep_agent
from langchain_modal import ModalSandbox
app = modal.App.lookup("your-app")
modal_sandbox = modal.Sandbox.create(app=app)
backend = ModalSandbox(sandbox=modal_sandbox)
agent = create_deep_agent(
model=ChatAnthropic(model="claude-sonnet-4-6"),
system_prompt="You are a coding assistant with sandbox access.",
backend=backend,
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Install numpy and calculate pi"}]}
)Cleanup
You are responsible for managing the sandbox lifecycle via Modal. When you are done, terminate the sandbox.
See also: Sandboxes.
AI 翻译查看英文原文