code-interpreter

Python 與 JS/TS SDK,可在您的 AI 應用程式中執行 AI 生成的程式碼與程式碼解譯

code-interpreter 是什麼?

Python 與 JS/TS SDK,專為在您的 AI 應用程式中執行 AI 生成的程式碼與程式碼解譯功能而設計。支援多種語言,讓您輕鬆整合程式碼執行與解譯能力。

code-interpreter 概覽

這是什麼

code-interpreter 是 E2B 推出的開源 SDK(支援 Python 與 JavaScript/TypeScript),讓你能在雲端安全隔離的沙盒中執行 AI 生成的程式碼。它提供簡單的介面來執行程式碼、擷取輸出,並管理沙盒的生命週期,適合用來打造需要安全執行不可信程式碼的 AI 應用。SDK 原始碼位於 E2B 的 monorepo 中,而此儲存庫則包含內建圖表資料擷取功能的沙盒範本。E2B 本身是一個開源基礎設施,用於在安全沙盒中執行 AI 生成的程式碼。

主要功能

  • 在安全隔離的雲端沙盒中執行 AI 生成的程式碼 - 同時支援 Python(e2b-code-interpreter)與 JavaScript/TypeScript(@e2b/code-interpreter)SDK - 執行程式碼並取得文字輸出、結果與錯誤訊息 - 可自訂沙盒範本:你可以建立自己的範本,加入額外套件或不同的執行環境 - 沙盒範本內建圖表資料擷取功能(template/charts) - 簡單的 API:建立沙盒、執行程式碼、取得執行結果

使用情境

  • 打造需要執行生成程式碼的 AI 助手(例如資料分析、圖表生成) - 在使用者或 AI 模型產生的不可信程式碼中提供安全執行環境 - 在 AI 應用中加入程式碼解譯功能 - 在不影響主機系統的情況下,原型測試 AI 生成的腳本 - 整合大型語言模型(LLM)以提供程式碼執行能力(請參考 E2B cookbook 中的範例)

快速開始

  1. 安裝 SDK: JavaScript / TypeScript npm i @e2b/code-interpreter Python pip install e2b-code-interpreter 2. 取得你的 E2B API 金鑰:在 E2B 註冊,取得 API 金鑰,然後設定環境變數: E2B_API_KEY=e2b_*** 3. 在沙盒中執行程式碼: JavaScript / TypeScript ts import { Sandbox } from '@e2b/code-interpreter' const sbx = await Sandbox.create() await sbx.runCode('x = 1') const execution = await sbx.runCode('x+=1; x') console.log(execution.text) // outputs 2 Python py from e2b_code_interpreter import Sandbox with Sandbox.create() as sandbox: sandbox.run_code('x = 1') execution = sandbox.run_code('x+=1; x') print(execution.text) # outputs 2 更多詳細資訊請參閱儲存庫的 README。

授權與價格

授權為 Apache-2.0。此專案為開源,所提供的資料中未提及任何價格資訊。

內容整理自該專案公開的 README 與儲存庫資訊。

將此徽章加入你的 README

Featured on YunoDB 徽章樣式與說明

你是這個專案的維護者嗎?展示它已收錄於 YunoDB。

Markdown[![Featured on YunoDB](https://yunodb.com/badge/e2b-devcode-interpreter.svg)](https://yunodb.com/tools/e2b-devcode-interpreter?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/e2b-devcode-interpreter?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/e2b-devcode-interpreter.svg" alt="Featured on YunoDB" height="20"></a>