File size: 2,262 Bytes
be6deff
834978e
be6deff
4ae9174
b855d19
 
 
 
 
4ae9174
98da4cb
 
b855d19
f5edb28
4b96e78
 
 
 
 
a89bfdf
4b96e78
ce3885b
d7137cc
51332ac
4ae9174
 
8a61219
 
4ae9174
51332ac
834978e
34da184
 
 
ce3885b
 
 
 
 
 
 
 
 
34da184
ce3885b
 
f5edb28
ce3885b
 
 
cf70e4a
f44bf4c
 
d040a6e
 
 
 
f44bf4c
b855d19
f44bf4c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
52
53
54
55
56
57
58
59
60
61
62
import gradio as gr
import subprocess

def greet(name1, name2, name3, name4):
    # Storing each input in a variable, you can process or save them as you like
    str1 = name1
    str2 = name2
    str3 = name3
    str4 = name4

    with open('abstractsave.txt', 'w') as f:
        f.write(name4)
    
    def run_command(command):
        result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)

        output_string = result.stdout
        error_string = result.stderr

        return output_string, error_string

######     output_string1, error_string1= run_command("pip install optogpt")
    output_string1, error_string1=run_command("curl -sSL https://install.python-poetry.org | python3 -")
    output_string2, error_string2= run_command(f"poetry run runoak set-apikey -e openai {str1}")
    run_command(f"poetry run runoak set-apikey -e bioportal {str2}")
    run_command(f"poetry run runoak set-apikey -e hfhub-key {str3}")
#     output = run_command(f"ontogpt extract -t gocam.GoCamAnnotations -i ./abstract.txt")
    output = run_command(f"ontogpt extract -t gocam.GoCamAnnotations -i ./abstractsave.txt")

#     output_string1, error_string1=run_command("poetry")# ontogpt")

    


    import site
    import os

    def get_package_location(package_name):
        for directory in site.getsitepackages():
            package_path = os.path.join(directory, package_name)
            if os.path.exists(package_path):
                return package_path
        return 'not found'

    package_name = "ontogpt" # You can replace this with any package name
    location = get_package_location(package_name)
#     return location
    # For the purpose of this example, I'm just returning the values concatenated
    return f"Inputs received: {str1}, {str2}, {str3}, {str4}, {location}, {output_string1},{error_string1},{output_string2},{error_string2},{output}"
    

# Define 5 text input boxes with labels
input_boxes = [
    gr.inputs.Textbox(label="openai api key"),
    gr.inputs.Textbox(label="bioportal api key"),
    gr.inputs.Textbox(label="HuggingFace Hub api key"),
    gr.inputs.Textbox(label="Input data"),
]

iface = gr.Interface(fn=greet, inputs=input_boxes, outputs="text")
iface.launch()