Docs: Updated instructions on importing third-party packages to Sandbox (#9890)

### What problem does this PR solve?


### Type of change

- [x] Documentation Update
This commit is contained in:
writinwaters
2025-09-03 15:47:07 +08:00
committed by GitHub
parent c832e0b858
commit 37ac7576f1

View File

@ -136,62 +136,57 @@ Please try again shortly or increase the pool size in the configuration to impro
### How to import my own Python or JavaScript packages into Sandbox? ### How to import my own Python or JavaScript packages into Sandbox?
To install the additional dependencies for your Python packages: To import your Python packages, update **sandbox_base_image/python/requirements.txt** to install the required dependencies. For example, to add the `openpyxl` package, proceed with the following command lines:
```bash ```bash {4,6}
(ragflow) ➜ ragflow/sandbox main ✓ pwd (ragflow) ➜ ragflow/sandbox main ✓ pwd # make sure you are in the right directory
/home/infiniflow/workspace/ragflow/sandbox
(ragflow) ➜ ragflow/sandbox main ✓ echo "openpyxl" >> sandbox_base_image/python/requirements.txt # add the package to the requirements.txt file
(ragflow) ➜ ragflow/sandbox main ✗ cat sandbox_base_image/python/requirements.txt # make sure the package is added
numpy
pandas
requests
openpyxl # here it is
(ragflow) ➜ ragflow/sandbox main ✗ make # rebuild the docker image, this command will rebuild the iamge and start the service immediately. To build image only, using `make build` instead.
(ragflow) ➜ ragflow/sandbox main ✗ docker exec -it sandbox_python_0 /bin/bash # entering container to check if the package is installed
# in the container
nobody@ffd8a7dd19da:/workspace$ python # launch python shell
Python 3.11.13 (main, Aug 12 2025, 22:46:03) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import openpyxl # import the package to verify installation
>>>
# That's okay!
``` ```
```bash To import your JavaScript packages, navigate to `sandbox_base_image/nodejs` and use `npm` to install the required packages. For example, to add the `lodash` package, run the following commands:
(ragflow) ➜ ragflow/sandbox main ✓ ls
```
```bash
(ragflow) ➜ ragflow/sandbox main ✓ echo "openpyxl" >> sandbox_base_image/python/requirements.txt
```
```bash
(ragflow) ➜ ragflow/sandbox main ✗ cat sandbox_base_image/python/requirements.txt
```
```bash
(ragflow) ➜ ragflow/sandbox main ✗ make
```
```bash
(ragflow) ➜ ragflow/sandbox main ✗ docker exec -it sandbox_python_0 /bin/bash
```
To install the additional dependencies for your JavaScript packages:
```bash ```bash
(ragflow) ➜ ragflow/sandbox main ✓ pwd (ragflow) ➜ ragflow/sandbox main ✓ pwd
/home/infiniflow/workspace/ragflow/sandbox /home/infiniflow/workspace/ragflow/sandbox
```
```bash
(ragflow) ➜ ragflow/sandbox main ✓ cd sandbox_base_image/nodejs (ragflow) ➜ ragflow/sandbox main ✓ cd sandbox_base_image/nodejs
```
```bash
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ npm install lodash (ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ npm install lodash
```
```bash (ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ cd ../.. # go back to sandbox root directory
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✗ make
make: *** No targets specified and no makefile found. Stop. (ragflow) ➜ ragflow/sandbox main ✗ make # rebuild the docker image, this command will rebuild the iamge and start the service immediately. To build image only, using `make build` instead.
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✗ lg
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ ls (ragflow) ➜ ragflow/sandbox main ✗ docker exec -it sandbox_nodejs_0 /bin/bash # entering container to check if the package is installed
node_modules Dockerfile package-lock.json package.json
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ cd .. # in the container
(ragflow) ➜ ragflow/sandbox/sandbox_base_image main ✓ ls nobody@dd4bbcabef63:/workspace$ npm list lodash # verify via npm list
nodejs python /workspace
(ragflow) ➜ ragflow/sandbox/sandbox_base_image main ✓ cd .. `-- lodash@4.17.21 extraneous
(ragflow) ➜ ragflow/sandbox main ✓ ls
asserts executor_manager sandbox_base_image scripts tests docker-compose.yml Makefile pyproject.toml README.md uv.lock nobody@dd4bbcabef63:/workspace$ ls node_modules | grep lodash # or verify via listing node_modules
(ragflow) ➜ ragflow/sandbox main ✓ pwd lodash
/home/infiniflow/workspace/ragflow/sandbox
(ragflow) ➜ ragflow/sandbox main ✓ cd sandbox_base_image/nodejs # That's okay!
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ npm install lodash
``` ```