akiko19191 commited on
Commit
01f6251
·
verified ·
1 Parent(s): e954578

Update tests.py

Browse files
Files changed (1) hide show
  1. tests.py +12 -2
tests.py CHANGED
@@ -15,7 +15,6 @@ from google import genai
15
  import pexpect
16
 
17
  client = genai.Client(api_key="AIzaSyDtP05TyoIy9j0uPL7_wLEhgQEE75AZQSc")
18
-
19
  source_dir = "/app/uploads/temp"
20
  destination_dir = "/app/code_interpreter"
21
  files_list=[]
@@ -31,6 +30,7 @@ import requests
31
  import os
32
  from bs4 import BeautifulSoup # For parsing HTML
33
 
 
34
 
35
  def download_all_files(base_url, files_endpoint, download_directory):
36
  """Downloads all files listed on the server's /upload page."""
@@ -140,6 +140,15 @@ 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=""
@@ -231,7 +240,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.
@@ -418,4 +427,5 @@ def deepthinking3(query:str,info:str) -> dict:
418
 
419
  if __name__ == "__main__":
420
  # Initialize and run the server
 
421
  mcp.run(transport='stdio')
 
15
  import pexpect
16
 
17
  client = genai.Client(api_key="AIzaSyDtP05TyoIy9j0uPL7_wLEhgQEE75AZQSc")
 
18
  source_dir = "/app/uploads/temp"
19
  destination_dir = "/app/code_interpreter"
20
  files_list=[]
 
30
  import os
31
  from bs4 import BeautifulSoup # For parsing HTML
32
 
33
+ Parent=pexpect.spawn('bash')
34
 
35
  def download_all_files(base_url, files_endpoint, download_directory):
36
  """Downloads all files listed on the server's /upload page."""
 
140
  session = FuturesSession()
141
 
142
  def run(cmd, timeout_sec,forever_cmd):
143
+ global Parent
144
+ if forever_cmd == 'true':
145
+ Parent.close()
146
+ Parent = pexpect.spawn("bash")
147
+ command="cd /app/code_interpreter/ && "+cmd
148
+
149
+ Parent.sendline(command)
150
+ Parent.readline.decode()
151
+ return str(Parent.readline.decode())
152
  t=time.time()
153
  child = pexpect.spawn("bash")
154
  output=""
 
240
  code: Full code to write to the file.
241
  start_cmd: Command to execute the file (e.g., "python /app/code_interpreter/app.py"
242
  or "bash /app/code_interpreter/app.py").
243
+ forever_cmd: If 'true', the command will run indefinitely.Set to 'true', when runnig a website/server.Run all servers/website on port 1337. If 'false', the command will time out after 300 second and the result will be returned.
244
  Notes:
245
  - All user-uploaded files are in /app/code_interpreter/.
246
  - After execution, embed a download link (or display images/gifs/videos directly in markdown format) in your response.
 
427
 
428
  if __name__ == "__main__":
429
  # Initialize and run the server
430
+ pexpect.spawn('ngrok http 1337')
431
  mcp.run(transport='stdio')