- 恶意代码注入:LLM 可能生成包含恶意逻辑的代码,导致系统资源被滥用或数据泄露;
- 环境破坏:执行的代码可能修改或删除重要文件,破坏运行环境稳定性;
- 跨用户影响:在多租户环境中,一个用户的恶意代码可能影响其他用户的正常使用;
code-interpreter-v1,您可以运行以下编程语言的代码:
如果您需要运行其他编程语言的代码,您可以通过 创建自定义模板 来支持。
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
code-interpreter-v1,您可以运行以下编程语言的代码:
如果您需要运行其他编程语言的代码,您可以通过 创建自定义模板 来支持。
import { Sandbox } from 'ppio-sandbox/code-interpreter';
const sandbox = await Sandbox.create();
const result = await sandbox.runCode(
`
import requests
response = requests.get("https://sandbox.ppio.cn/health")
print(response.text)
`,
{ language: "python" }
);
console.log(result);
await sandbox.kill();
from ppio_sandbox.code_interpreter import Sandbox
sandbox = Sandbox.create()
result = sandbox.run_code("""
import requests
response = requests.get("https://sandbox.ppio.cn/health")
print(response.text)""", language="python")
print(result)
sandbox.kill()
import { Sandbox } from 'ppio-sandbox/code-interpreter';
// Create a new sandbox
const sandbox = await Sandbox.create();
await sandbox.commands.run('npm install axios');
// Run the code
const execution = await sandbox.runCode(`
import axios from "axios";
const url: string = "https://sandbox.ppio.cn/health";
const response = await axios.get(url);
console.log(response.data);
`,
{ language: "ts" }
);
console.log(execution);
await sandbox.kill();
from ppio_sandbox.code_interpreter import Sandbox
# Create a new sandbox
sandbox = Sandbox.create()
# Install the axios package
sandbox.commands.run('npm install axios')
# Run the code
execution = sandbox.run_code("""
import axios from "axios";
const url: string = "https://sandbox.ppio.cn/health";
const response = await axios.get(url);
console.log(response.data);""", language="ts")
print(execution)
sandbox.kill()
import { Sandbox } from 'ppio-sandbox/code-interpreter';
const sandbox = await Sandbox.create();
const result = await sandbox.runCode(
`
url <- "https://sandbox.ppio.cn/health"
content <- readLines(url, warn = FALSE)
print(paste(content, collapse = "\\n"))
`,
{ language: "r" }
);
console.log(result);
await sandbox.kill();
from ppio_sandbox.code_interpreter import Sandbox
sandbox = Sandbox.create()
result = sandbox.run_code("""
url <- "https://sandbox.ppio.cn/health"
content <- readLines(url, warn = FALSE)
print(paste(content, collapse = "\\n"))""", language="r")
print(result)
sandbox.kill()
import { Sandbox } from 'ppio-sandbox/code-interpreter';
const sandbox = await Sandbox.create();
const execution = await sandbox.runCode(`
import java.net.*;
import java.io.*;
URL url = new URL("https://sandbox.ppio.cn/health");HttpURLConnection con = (HttpURLConnection) url.openConnection();con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
con.disconnect();
System.out.println(content.toString());
`, { language: 'java' });
console.log(execution);
await sandbox.kill();
from ppio_sandbox.code_interpreter import Sandbox
sandbox = Sandbox.create()
execution = sandbox.run_code("""
import java.net.*;
import java.io.*;
URL url = new URL("https://sandbox.ppio.cn/health");HttpURLConnection con = (HttpURLConnection) url.openConnection();con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
con.disconnect();
System.out.println(content.toString());""", language="java")
print(execution)
sandbox.kill()
import { Sandbox } from 'ppio-sandbox/code-interpreter';
const sandbox = await Sandbox.create();
const execution = await sandbox.runCode(
'curl -s https://sandbox.ppio.cn/health',
{ language: 'bash' },
);
console.log(execution);
await sandbox.kill();
from ppio_sandbox.code_interpreter import Sandbox
sandbox = Sandbox.create()
execution = sandbox.run_code(
'curl -s https://sandbox.ppio.cn/health',
language='bash'
)
print(execution)
sandbox.kill()