Spaces:
Running
Running
Commit
·
78b66c2
1
Parent(s):
cabdc7a
add requiretment
Browse files
app.py
CHANGED
@@ -2,62 +2,64 @@ import gradio as gr
|
|
2 |
import subprocess
|
3 |
|
4 |
|
5 |
-
def greet(name):
|
6 |
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
|
15 |
|
16 |
-
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
17 |
-
demo.launch()
|
18 |
|
19 |
|
20 |
-
|
21 |
-
#
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
#
|
44 |
-
|
45 |
|
46 |
-
#
|
47 |
|
48 |
|
49 |
-
#
|
50 |
-
#
|
51 |
-
# return f"Inputs received: {str1}, {str2}, {str3}, {str4}, '--------------', '--------------', {output_string1},{error_string1},{output_string2},{error_string2},{output}"
|
52 |
-
|
|
|
|
|
53 |
|
54 |
-
#
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
|
62 |
-
|
63 |
-
|
|
|
2 |
import subprocess
|
3 |
|
4 |
|
5 |
+
# def greet(name):
|
6 |
|
7 |
+
# def run_command(command):
|
8 |
+
# result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
9 |
|
10 |
+
# output_string = result.stdout
|
11 |
+
# error_string = result.stderr
|
12 |
|
13 |
+
# output_string, error_string= run_command("pwd")
|
14 |
+
# return "Hello " + output_string + error_string + "!"
|
15 |
|
16 |
+
# demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
17 |
+
# demo.launch()
|
18 |
|
19 |
|
20 |
+
def greet(name1, name2, name3, name4):
|
21 |
+
# Storing each input in a variable, you can process or save them as you like
|
22 |
+
str1 = name1
|
23 |
+
str2 = name2
|
24 |
+
str3 = name3
|
25 |
+
str4 = name4
|
26 |
+
|
27 |
+
with open('abstractsave.txt', 'w') as f:
|
28 |
+
f.write(name4)
|
29 |
|
30 |
+
def run_command(command):
|
31 |
+
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
32 |
|
33 |
+
output_string = result.stdout
|
34 |
+
error_string = result.stderr
|
35 |
|
36 |
+
return output_string, error_string
|
37 |
|
38 |
+
###### output_string1, error_string1= run_command("pip install optogpt")
|
39 |
+
output_string1, error_string1=run_command("curl -sSL https://install.python-poetry.org | python3 -")
|
40 |
+
output_string2, error_string2= run_command(f"poetry run runoak set-apikey -e openai {str1}")
|
41 |
+
run_command(f"poetry run runoak set-apikey -e bioportal {str2}")
|
42 |
+
run_command(f"poetry run runoak set-apikey -e hfhub-key {str3}")
|
43 |
+
# output = run_command(f"ontogpt extract -t gocam.GoCamAnnotations -i ./abstract.txt")
|
44 |
+
output = run_command(f"ontogpt extract -t gocam.GoCamAnnotations -i ./abstractsave.txt")
|
45 |
|
46 |
+
# output_string1, error_string1=run_command("poetry")# ontogpt")
|
47 |
|
48 |
|
49 |
+
# return location
|
50 |
+
# For the purpose of this example, I'm just returning the values concatenated
|
51 |
+
# return f"Inputs received: {str1} \n, {str2}, {str3}, {str4}, '--------------', '--------------', {output_string1},{error_string1},{output_string2},{error_string2},{output}"
|
52 |
+
# # return location
|
53 |
+
# For the purpose of this example, I'm just returning the values concatenated
|
54 |
+
return f"{output}"
|
55 |
|
56 |
+
# Define 5 text input boxes with labels
|
57 |
+
input_boxes = [
|
58 |
+
gr.inputs.Textbox(label="openai api key"),
|
59 |
+
gr.inputs.Textbox(label="bioportal api key"),
|
60 |
+
gr.inputs.Textbox(label="HuggingFace Hub api key"),
|
61 |
+
gr.inputs.Textbox(label="Input data"),
|
62 |
+
]
|
63 |
|
64 |
+
iface = gr.Interface(fn=greet, inputs=input_boxes, outputs="text")
|
65 |
+
iface.launch()
|