akiko19191 commited on
Commit
d3d0ccb
·
verified ·
1 Parent(s): 4a89ff2

Update tests.py

Browse files
Files changed (1) hide show
  1. tests.py +10 -10
tests.py CHANGED
@@ -139,7 +139,7 @@ chat_id = "5075390513"
139
  from requests_futures.sessions import FuturesSession
140
  session = FuturesSession()
141
 
142
- def run(cmd, timeout_sec,forever_cmd=False):
143
  t=time.time()
144
  child = pexpect.spawn("bash")
145
  output=""
@@ -159,7 +159,7 @@ def run(cmd, timeout_sec,forever_cmd=False):
159
  output=output.replace("END","")
160
  child.close()
161
  break
162
- if forever_cmd:
163
  break
164
  return output
165
 
@@ -221,7 +221,7 @@ def create_code_files(filename: str, code: str) -> dict:
221
  return {"info":"task completed. The referenced code files were created successfully. "}
222
 
223
  @mcp.tool()
224
- def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_cmd:bool) -> dict:
225
  """
226
  Execute code in a controlled environment with package installation and file handling.
227
  Args:
@@ -231,7 +231,7 @@ def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_
231
  code: Full code to write to the file.
232
  start_cmd: Command to execute the file (e.g., "python /app/code_interpreter/app.py"
233
  or "bash /app/code_interpreter/app.py").
234
- forever_cmd: If True, the command will run indefinitely.Set to True, when runnig a website/server. If False, the command will time out after 300 second and the result will be returned.
235
  Notes:
236
  - All user-uploaded files are in /app/code_interpreter/.
237
  - After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
@@ -249,7 +249,7 @@ def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_
249
  f.write(code)
250
  f.close()
251
  global files_list
252
- stdot=run(start_cmd, 300)
253
  onlyfiles = glob.glob("/app/code_interpreter/*")
254
  onlyfiles=list(set(onlyfiles)-set(files_list))
255
  uploaded_filenames=[]
@@ -264,8 +264,8 @@ def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_
264
 
265
 
266
  @mcp.tool()
267
- def run_code_files(start_cmd:str,forever_cmd:bool) -> dict:
268
- """(start_cmd:Example- python /app/code_interpreter/app.py or bash /app/code_interpreter/app.py).The files must be inside the /app/code_interpreter directory.forever_cmd:If True, the command will run indefinitely.Set to True, when runnig a website/server. If False, the command will time out after 300 second and the result will be returned."""
269
  global files_list
270
 
271
  stdot=run(start_cmd, 300,forever_cmd)
@@ -283,8 +283,8 @@ def run_code_files(start_cmd:str,forever_cmd:bool) -> dict:
283
 
284
 
285
  @mcp.tool()
286
- def run_shell_command(cmd:str,forever_cmd:bool) -> dict:
287
- """(cmd:Example- mkdir test.By default , the command is run inside the /app/code_interpreter/ directory.).Remember, the code_interpreter is running on **alpine linux** , so write commands accordingly.Eg-sudo does not work and is not required. forever_cmd: If True, the command will run indefinitely.Set to True, when running a website/server. If False, the command will time out after 300 second and the result will be returned."""
288
  output=run(cmd, 300,forever_cmd)
289
  transfer_files()
290
  return {"output":output}
@@ -417,4 +417,4 @@ def deepthinking3(query:str,info:str) -> dict:
417
 
418
  if __name__ == "__main__":
419
  # Initialize and run the server
420
- mcp.run(transport='stdio')
 
139
  from requests_futures.sessions import FuturesSession
140
  session = FuturesSession()
141
 
142
+ def run(cmd, timeout_sec,forever_cmd):
143
  t=time.time()
144
  child = pexpect.spawn("bash")
145
  output=""
 
159
  output=output.replace("END","")
160
  child.close()
161
  break
162
+ if "true" in forever_cmd:
163
  break
164
  return output
165
 
 
221
  return {"info":"task completed. The referenced code files were created successfully. "}
222
 
223
  @mcp.tool()
224
+ def run_code(python_packages:str,filename: str, code: str,start_cmd:str,forever_cmd:str) -> dict:
225
  """
226
  Execute code in a controlled environment with package installation and file handling.
227
  Args:
 
231
  code: Full code to write to the file.
232
  start_cmd: Command to execute the file (e.g., "python /app/code_interpreter/app.py"
233
  or "bash /app/code_interpreter/app.py").
234
+ forever_cmd: If 'true', the command will run indefinitely.Set to 'true', when runnig a website/server. If 'false', the command will time out after 300 second and the result will be returned.
235
  Notes:
236
  - All user-uploaded files are in /app/code_interpreter/.
237
  - After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
 
249
  f.write(code)
250
  f.close()
251
  global files_list
252
+ stdot=run(start_cmd, 300,forever_cmd)
253
  onlyfiles = glob.glob("/app/code_interpreter/*")
254
  onlyfiles=list(set(onlyfiles)-set(files_list))
255
  uploaded_filenames=[]
 
264
 
265
 
266
  @mcp.tool()
267
+ def run_code_files(start_cmd:str,forever_cmd:str) -> dict:
268
+ """(start_cmd:Example- python /app/code_interpreter/app.py or bash /app/code_interpreter/app.py).The files must be inside the /app/code_interpreter directory.forever_cmd:If 'true', the command will run indefinitely.Set to 'true', when running a website/server. If 'false', the command will time out after 300 second and the result will be returned."""
269
  global files_list
270
 
271
  stdot=run(start_cmd, 300,forever_cmd)
 
283
 
284
 
285
  @mcp.tool()
286
+ def run_shell_command(cmd:str,forever_cmd:str) -> dict:
287
+ """(cmd:Example- mkdir test.By default , the command is run inside the /app/code_interpreter/ directory.).Remember, the code_interpreter is running on **alpine linux** , so write commands accordingly.Eg-sudo does not work and is not required.forever_cmd: If 'true', the command will run indefinitely.Set to 'true', when running a website/server. If 'false', the command will time out after 300 second and the result will be returned."""
288
  output=run(cmd, 300,forever_cmd)
289
  transfer_files()
290
  return {"output":output}
 
417
 
418
  if __name__ == "__main__":
419
  # Initialize and run the server
420
+ mcp.run(transport='stdio')