akiko19191 commited on
Commit
23dda64
·
verified ·
1 Parent(s): cbb4221

Update tests.py

Browse files
Files changed (1) hide show
  1. tests.py +14 -8
tests.py CHANGED
@@ -217,12 +217,14 @@ def create_code_files(filename: str, code) -> dict:
217
 
218
 
219
  @mcp.tool()
220
- def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_cmd:str) -> dict:
221
  """
222
  Execute code in a controlled environment with package installation and file handling.
223
  Args:
224
- python_packages[Output an empty string ,if using any other language.]: Space-separated list of packages to install (e.g., "numpy matplotlib").
225
- Preinstalled packages: gradio, XlsxWriter, openpyxl.
 
 
226
  filename: Name of the file to create (stored in /app/code_interpreter/).
227
  code: Full code to write to the file.
228
  start_cmd: Command to execute the file (e.g., "python /app/code_interpreter/app.py"
@@ -231,13 +233,19 @@ def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_
231
  Notes:
232
  - All user-uploaded files are in /app/code_interpreter/.
233
  - After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
 
 
 
234
  """
235
  global destination_dir
236
- package_names = python_packages.strip()
237
- command="pip install"
 
 
 
238
  if package_names != "" or package_names != " ":
239
  stdot=run(
240
- f"{command} --break-system-packages {package_names}", timeout_sec=300,forever_cmd= 'false'
241
  )
242
  transfer_files2()
243
  transfer_files()
@@ -308,8 +316,6 @@ def run_shell_command(cmd:str,forever_cmd:str) -> dict:
308
  compatible .
309
  - `sudo` commands are restricted for security reasons.Hence commands which require elevated privelages like `apk add` CANNOT be executed.Instead try to use `pip install` or `npm install` commands.
310
  - Standard bash features like `&&`, `||`, pipes (`|`), etc., are supported.
311
- - When installing python packages , add an argument --break-system-packages to the pip install command.
312
- - The following npm packages are preinstalled: express ejs chart.js .Any additional packages can be installed with npm install command.
313
  Args:
314
  cmd (str): The shell command to execute.
315
  Example: ``mkdir test_dir && ls -l``
 
217
 
218
 
219
  @mcp.tool()
220
+ def run_code(language:str,packages:str,filename: str, code: str,start_cmd:str,forever_cmd:str) -> dict:
221
  """
222
  Execute code in a controlled environment with package installation and file handling.
223
  Args:
224
+ language:Programming language of the code (Currently Supported:"python", "nodejs", "bash").
225
+ packages: Space-separated list of packages to install (e.g., "numpy matplotlib").
226
+ Preinstalled python packages: gradio, XlsxWriter, openpyxl.
227
+ Preinstalled npm packages: express, ejs, chart.js.
228
  filename: Name of the file to create (stored in /app/code_interpreter/).
229
  code: Full code to write to the file.
230
  start_cmd: Command to execute the file (e.g., "python /app/code_interpreter/app.py"
 
233
  Notes:
234
  - All user-uploaded files are in /app/code_interpreter/.
235
  - After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
236
+ - bash/apk packages cannot be installed.
237
+ - When editing and subsequently re-executing the server with the forever_cmd='true' setting, the previous server instance will be automatically terminated, and the updated server will commence operation. This functionality negates the requirement for manual process termination commands such as pkill node.
238
+
239
  """
240
  global destination_dir
241
+ package_names = packages.strip()
242
+ if "python" in language:
243
+ command="pip install --break-system-packages "
244
+ elif "node" in language:
245
+ command="npm install "
246
  if package_names != "" or package_names != " ":
247
  stdot=run(
248
+ f"{command} {package_names}", timeout_sec=300,forever_cmd= 'false'
249
  )
250
  transfer_files2()
251
  transfer_files()
 
316
  compatible .
317
  - `sudo` commands are restricted for security reasons.Hence commands which require elevated privelages like `apk add` CANNOT be executed.Instead try to use `pip install` or `npm install` commands.
318
  - Standard bash features like `&&`, `||`, pipes (`|`), etc., are supported.
 
 
319
  Args:
320
  cmd (str): The shell command to execute.
321
  Example: ``mkdir test_dir && ls -l``