code interpreter
@e2b
E2B是一种开源基础架构,可让您在云中的安全隔离沙箱中运行到AI生成的代码。要启动和控制沙箱,请使用我们的JavaScript SDK或Python SDK。
JavaScript /打字稿
npm i @e2b/code-interpreter
Python
pip install e2b-code-interpreter
E2B_API_KEY=e2b_***
JavaScript /打字稿
import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox . create ( )
await sbx . runCode ( 'x = 1' )
const execution = await sbx . runCode ( 'x+=1; x' )
console . log ( execution . text ) // outputs 2
Python
from e2b_code_interpreter import Sandbox
with Sandbox () as sandbox :
sandbox . run_code ( "x = 1" )
execution = sandbox . run_code ( "x+=1; x" )
print ( execution . text ) # outputs 2
访问E2B文档。
请访问我们的食谱,以受到不同LLM和AI框架的示例的启发。