File size: 3,012 Bytes
be6deff
834978e
be6deff
8392b33
d8a8ced
4b96e78
d8a8ced
 
6aaa0db
d8a8ced
0ecf059
b18cd84
6f9e91f
78b66c2
1ecd2bc
 
 
 
a23a68c
2b0664d
78b66c2
1ecd2bc
624e912
1ecd2bc
 
6aaa0db
1ecd2bc
 
4b96e78
1ecd2bc
4b96e78
1ecd2bc
 
 
 
 
624e912
1ecd2bc
2b0664d
c129d7d
4c644f1
 
 
 
 
 
 
 
 
 
 
 
624e912
4863bc1
 
 
 
 
 
 
4ae9174
1ecd2bc
834978e
34da184
78b66c2
 
 
 
 
4863bc1
cf70e4a
78b66c2
 
969d05d
48963dc
78b66c2
b855d19
4863bc1
 
78b66c2
8392b33
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import gradio as gr
import subprocess

'''
import gradio as gr

def greet(name):
    return "Hello " + name + "!"

demo = gr.Interface(fn=greet, inputs="text", outputs="text")
demo.launch()
'''
def greet(name1, name2):
    # Storing each input in a variable, you can process or save them as you like
    str1_openai = name1 ## openai
    str2_bioportal = "213e22ba-4c3b-402b-bd36-6e9d4e86b1b5"   #bioportal
    str3_huggingface = "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"   # huggingface
    str4_input = name2
    
    
    with open('abstractsave.txt', 'w') as f:
        f.write(str4_input)
    '''
    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_openai}")
    run_command(f"poetry run runoak set-apikey -e bioportal {str2_bioportal}")
    run_command(f"poetry run runoak set-apikey -e hfhub-key {str3_huggingface}")
#####     output = run_command(f"ontogpt extract -t gocam.GoCamAnnotations -i ./abstract.txt")
    output = run_command(f"cancerontogpt extract -t cancer.CancerAnnotations -i ./abstractsave.txt")
    
    output = output[0].replace('\\n', '\n')
    
    # Find the positions of the start and end markers
    start_marker = "raw_completion_output: |-"
    end_marker = "prompt: "
    start_position = output.find(start_marker)
    end_position = output.find(end_marker)

    # Extract the text between the start and end positions
    output = output[start_position + len(start_marker):end_position].strip()

    # Output the extracted text
    output
    '''
    data = {
        "Name": [name, name, name],
        "Age": [30, 25, 35],
        "City": ["New York", "San Francisco", "Los Angeles"]
    }
    df = pd.DataFrame(data)
    return df.to_html()

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

    
#     return location
    # For the purpose of this example, I'm just returning the values concatenated
#     return f"Inputs received: {str1} \n, {str2}, {str3}, {str4}, '--------------',   '--------------', {output_string1},{error_string1},{output_string2},{error_string2},{output}"
#     #     return location
    # For the purpose of this example, I'm just returning the values concatenated
#     return f"{str4_input}"

# Define 5 text input boxes with labels
input_boxes = [
    gr.inputs.Textbox(label="openai api key"),
    gr.inputs.Textbox(lines=20,label="Input cencer report"),
]

# iface = gr.Interface(fn=greet, inputs=input_boxes, outputs="text")
iface = gr.Interface(fn=greet, inputs=input_boxes, gr.outputs.HTML(label="Output Table"))
iface.launch()