Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit 3cd8a57

Browse files
authored
feat: update interpreter to always upload all files in the configured directory (#2057)
1 parent 09c6077 commit 3cd8a57

4 files changed

Lines changed: 998 additions & 313 deletions

File tree

.changeset/ripe-trains-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@llamaindex/tools": patch
3+
---
4+
5+
update interpreter to always upload all files in the configured directory

packages/tools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"dependencies": {
4848
"@apidevtools/swagger-parser": "^10.1.0",
49-
"@e2b/code-interpreter": "^1.0.4",
49+
"@e2b/code-interpreter": "^1.5.1",
5050
"@modelcontextprotocol/sdk": "^1.13.0",
5151
"duck-duck-scrape": "^2.2.5",
5252
"formdata-node": "^6.0.3",

packages/tools/src/tools/interpreter.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,13 @@ export const interpreter = (params: InterpreterToolParams) => {
5757
"Execute python code in a Jupyter notebook cell and return any result, stdout, stderr, display_data, and error.",
5858
parameters: z.object({
5959
code: z.string().describe("The python code to execute in a single cell"),
60-
sandboxFiles: z
61-
.array(z.string())
62-
.optional()
63-
.describe("List of local file paths to be used by the code"),
6460
retryCount: z
6561
.number()
6662
.default(0)
6763
.optional()
6864
.describe("The number of times the tool has been retried"),
6965
}),
70-
execute: async ({ code, sandboxFiles, retryCount = 0 }) => {
66+
execute: async ({ code, retryCount = 0 }) => {
7167
if (retryCount >= 3) {
7268
return {
7369
isError: true,
@@ -78,7 +74,7 @@ export const interpreter = (params: InterpreterToolParams) => {
7874
}
7975

8076
const interpreter = await Sandbox.create({ apiKey });
81-
await uploadFilesToSandbox(interpreter, uploadedFilesDir, sandboxFiles);
77+
await uploadFilesToSandbox(interpreter, uploadedFilesDir);
8278
const exec = await interpreter.runCode(code);
8379
const extraResult = await getExtraResult(
8480
outputDir,
@@ -100,9 +96,9 @@ export const interpreter = (params: InterpreterToolParams) => {
10096
async function uploadFilesToSandbox(
10197
codeInterpreter: Sandbox,
10298
uploadedFilesDir: string,
103-
sandboxFiles: string[] = [],
10499
) {
105100
try {
101+
const sandboxFiles = fs.readdirSync(uploadedFilesDir);
106102
for (const filePath of sandboxFiles) {
107103
const fileName = path.basename(filePath);
108104
const localFilePath = path.join(uploadedFilesDir, fileName);

0 commit comments

Comments
 (0)