Demo Here
The following outlines the custom integration of e2b.dev
tools within Dify.ai. This configuration enables a flexible environment for executing scripts with specific pre-configured settings. Below are key parameters essential for using e2b.dev
within Dify. You can import the DSL from Matlab Scientists Demo.yml
The first parameter is the code itself, representing the complete script or program you intend to run. For example, if you are using Python to solve a computation problem, you would import the necessary Python packages, perform the computation, and then output the results.
The programming language for the code is selectable via a dropdown menu. e2b.dev
supports several languages, including Python, JavaScript, R, Java, and Bash. In this setup, Python is pre-selected, but it can be changed by modifying the dropdown. Alternatively, you could alter the source code to allow this parameter to be set dynamically rather than predefined.
For Python, an essential feature of e2b.dev
is its ability to preload specific Python packages and package them within different Sandbox environments. You can reference these environments by their Template ID. By specifying the Template ID, users can seamlessly invoke a predefined environment loaded with specific packages.
- Documentation for initializing a sandbox template: Initialize Sandbox Template
- For installing custom Python packages during runtime, refer to: Install Packages During Sandbox Runtime
One advantage of using Template IDs to specify environments is that it allows users to switch environments without needing to modify Dify’s Source Code for each Python package. This setup is particularly useful for users who may require flexibility in environment specification across different machines, as they can simply use the API key and Template ID for similar results. This approach may offer more flexibility than Dify’s native Sandbox but requires more maintenance for source code compatibility with Dify. Ideally, future improvements could include simplified user-defined Tool integrations within Dify.
- The showcased code here is experimental and was fully generated by Claude.ai. Many thanks to it for the contribution. 🙏
- Please note that you need to run Dify using the source code startup method. The tutorial can be found here. Additionally, you will need to use poetry to install the e2b.dev python sdk.