e2b-dev / code-interpreter

Python & JS/TS SDK for adding code interpreting to your AI app
https://e2b.dev
Apache License 2.0
1.08k stars 74 forks source link

Import dependency to execute code #28

Closed 404notfoundyc-L closed 2 weeks ago

404notfoundyc-L commented 2 months ago

How to execute the code with sandbox of the imported package? For example: image

mlejva commented 2 months ago

Hi @404notfoundyc-L are you asking how to install a dependency inside a sandbox?

I'm not sure from what app is the UI you shared - that's not from us so not sure how they're handling it

404notfoundyc-L commented 2 months ago

Hi @404notfoundyc-L are you asking how to install a dependency inside a sandbox?

I'm not sure from what app is the UI you shared - that's not from us so not sure how they're handling it

yes, I want to know how to install a dependency inside a sandbox. As the image I provided shows, I want to be able to customize and install some third-party dependencies to run the code.

mlejva commented 2 months ago

@404notfoundyc-L check out custom sandboxes. You can create your own custom sandbox with dependencies preinstalled. The other option is to install dependencies dynamically during runtime. You can do that by starting any process inside the sandbox (docs)

JS/TS

await sandbox.process.startAndWait("npm i ...")

Python

sandbox.process.start_and_wait("npm i ...")
ValentaTomas commented 1 month ago

Hey @404notfoundyc-L, were you able to use the custom dependencies with your project?

cy1665 commented 1 month ago

Hey @404notfoundyc-L, were you able to use the custom dependencies with your project?

yes, I install custom dependency with sandbox.process successfully. Thank you!