Skip to content

Commit 37ac757

Browse files
authored
Docs: Updated instructions on importing third-party packages to Sandbox (infiniflow#9890)
### What problem does this PR solve? ### Type of change - [x] Documentation Update
1 parent c832e0b commit 37ac757

File tree

1 file changed

+36
-41
lines changed
  • docs/guides/agent/agent_component_reference

1 file changed

+36
-41
lines changed

docs/guides/agent/agent_component_reference/code.mdx

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -136,62 +136,57 @@ Please try again shortly or increase the pool size in the configuration to impro
136136

137137
### How to import my own Python or JavaScript packages into Sandbox?
138138

139-
To install the additional dependencies for your Python packages:
139+
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:
140140

141-
```bash
142-
(ragflow) ➜ ragflow/sandbox main ✓ pwd
143-
```
141+
```bash {4,6}
142+
(ragflow) ➜ ragflow/sandbox main ✓ pwd # make sure you are in the right directory
143+
/home/infiniflow/workspace/ragflow/sandbox
144144

145-
```bash
146-
(ragflow) ➜ ragflow/sandbox main ✓ ls
147-
```
145+
(ragflow) ➜ ragflow/sandbox main ✓ echo "openpyxl" >> sandbox_base_image/python/requirements.txt # add the package to the requirements.txt file
148146

149-
```bash
150-
(ragflow) ➜ ragflow/sandbox main ✓ echo "openpyxl" >> sandbox_base_image/python/requirements.txt
151-
```
147+
(ragflow) ➜ ragflow/sandbox main ✗ cat sandbox_base_image/python/requirements.txt # make sure the package is added
148+
numpy
149+
pandas
150+
requests
151+
openpyxl # here it is
152152

153-
```bash
154-
(ragflow) ➜ ragflow/sandbox main ✗ cat sandbox_base_image/python/requirements.txt
155-
```
153+
(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.
156154

157-
```bash
158-
(ragflow) ➜ ragflow/sandbox main ✗ make
159-
```
155+
(ragflow) ➜ ragflow/sandbox main ✗ docker exec -it sandbox_python_0 /bin/bash # entering container to check if the package is installed
160156

161-
```bash
162-
(ragflow) ➜ ragflow/sandbox main ✗ docker exec -it sandbox_python_0 /bin/bash
157+
158+
# in the container
159+
nobody@ffd8a7dd19da:/workspace$ python # launch python shell
160+
Python 3.11.13 (main, Aug 12 2025, 22:46:03) [GCC 12.2.0] on linux
161+
Type "help", "copyright", "credits" or "license" for more information.
162+
>>> import openpyxl # import the package to verify installation
163+
>>>
164+
# That's okay!
163165
```
164166

165-
To install the additional dependencies for your JavaScript packages:
167+
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:
166168

167169
```bash
168170
(ragflow) ➜ ragflow/sandbox main ✓ pwd
169171
/home/infiniflow/workspace/ragflow/sandbox
170172

171-
```
172-
173-
```bash
174173
(ragflow) ➜ ragflow/sandbox main ✓ cd sandbox_base_image/nodejs
175-
```
176174

177-
```bash
178175
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ npm install lodash
179-
```
180176

181-
```bash
182-
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✗ make
183-
make: *** No targets specified and no makefile found. Stop.
184-
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✗ lg
185-
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ ls
186-
node_modules Dockerfile package-lock.json package.json
187-
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ cd ..
188-
(ragflow) ➜ ragflow/sandbox/sandbox_base_image main ✓ ls
189-
nodejs python
190-
(ragflow) ➜ ragflow/sandbox/sandbox_base_image main ✓ cd ..
191-
(ragflow) ➜ ragflow/sandbox main ✓ ls
192-
asserts executor_manager sandbox_base_image scripts tests docker-compose.yml Makefile pyproject.toml README.md uv.lock
193-
(ragflow) ➜ ragflow/sandbox main ✓ pwd
194-
/home/infiniflow/workspace/ragflow/sandbox
195-
(ragflow) ➜ ragflow/sandbox main ✓ cd sandbox_base_image/nodejs
196-
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ npm install lodash
177+
(ragflow) ➜ ragflow/sandbox/sandbox_base_image/nodejs main ✓ cd ../.. # go back to sandbox root directory
178+
179+
(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.
180+
181+
(ragflow) ➜ ragflow/sandbox main ✗ docker exec -it sandbox_nodejs_0 /bin/bash # entering container to check if the package is installed
182+
183+
# in the container
184+
nobody@dd4bbcabef63:/workspace$ npm list lodash # verify via npm list
185+
/workspace
186+
`-- lodash@4.17.21 extraneous
187+
188+
nobody@dd4bbcabef63:/workspace$ ls node_modules | grep lodash # or verify via listing node_modules
189+
lodash
190+
191+
# That's okay!
197192
```

0 commit comments

Comments
 (0)