Documentation Index
Fetch the complete documentation index at: https://novita.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Reading files
You can read files from the sandbox filesystem using the files.read() method.
import { Sandbox } from 'novita-sandbox/code-interpreter'
const sandbox = await Sandbox.create()
// Create a file in the sandbox for testing
const filePathInSandbox = '/tmp/test-file'
await sandbox.files.write(filePathInSandbox, "test-file-content")
const fileContent = await sandbox.files.read(filePathInSandbox)
console.log(fileContent)
await sandbox.kill()
Writing single files
You can write single files to the sandbox filesystem using the files.write() method.
import { Sandbox } from 'novita-sandbox/code-interpreter'
const sandbox = await Sandbox.create()
const filePathInSandbox = '/tmp/test-file'
const result = await sandbox.files.write(filePathInSandbox, "test-file-content")
console.log(result)
await sandbox.kill()
Writing multiple files
You can also write multiple files to the sandbox filesystem using the files.write() method.
import { Sandbox } from 'novita-sandbox/code-interpreter'
const sandbox = await Sandbox.create()
const result = await sandbox.files.write([
{ path: '/tmp/test-file-1', data: 'file content 1' },
{ path: '/tmp/test-file-2', data: 'file content 2' }
])
console.log(result)
await sandbox.kill()