ruslanmv commited on
Commit
1816e1b
·
verified ·
1 Parent(s): 559b8d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -16
app.py CHANGED
@@ -1,3 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
  from langchain.embeddings import HuggingFaceEmbeddings, HuggingFaceInstructEmbeddings, OpenAIEmbeddings
@@ -198,27 +222,13 @@ with gr.Blocks(
198
  inputs=[input_box, top_k, score, db_col_textbox, db_index_textbox],
199
  outputs=[output_box])
200
 
201
-
202
-
203
 
204
- def on_click_run_command():
205
- input_text = input_cmd.get_value()
206
- result = run_command(input_text)
207
- output_cmd.set_value(result)
208
-
209
- with gr.Tab("Command Viewer"):
210
- with gr.Row():
211
- input_cmd = gr.Textbox(label="Command", placeholder="Enter a command")
212
- output_cmd = gr.Label("", label="Command Output")
213
- btn_cmd = gr.Button(onclick=on_click_run_command, text="Run Command")
214
 
215
- btn_cmd.click(fn=on_click_run_command, inputs=[input_cmd], outputs=[output_cmd])
216
-
217
-
218
-
219
 
220
  if __name__ == "__main__":
221
  demo.queue()
222
  demo.launch(server_name="0.0.0.0",
223
  server_port=7860)
224
 
 
 
1
+
2
+ import gradio as gr
3
+ import subprocess
4
+ def run_command(command):
5
+ try:
6
+ result = subprocess.check_output(command, shell=True, text=True)
7
+ return result
8
+ except subprocess.CalledProcessError as e:
9
+ return f"Error: {e}"
10
+ iface = gr.Interface(
11
+ fn=run_command,
12
+ inputs="text",
13
+ outputs="text",
14
+ #live=True,
15
+ title="Command Output Viewer",
16
+ description="Enter a command and view its output.",
17
+ examples=[
18
+ ["ls"],
19
+ ["pwd"],
20
+ ["echo 'Hello, Gradio!'"],
21
+ ["python --version"]]
22
+ )
23
+ iface.launch(server_name="0.0.0.0", server_port=7860)
24
+ '''
25
  import gradio as gr
26
 
27
  from langchain.embeddings import HuggingFaceEmbeddings, HuggingFaceInstructEmbeddings, OpenAIEmbeddings
 
222
  inputs=[input_box, top_k, score, db_col_textbox, db_index_textbox],
223
  outputs=[output_box])
224
 
225
+
 
226
 
 
 
 
 
 
 
 
 
 
 
227
 
 
 
 
 
228
 
229
  if __name__ == "__main__":
230
  demo.queue()
231
  demo.launch(server_name="0.0.0.0",
232
  server_port=7860)
233
 
234
+ '''