Spaces:
Sleeping
Sleeping
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 = """ut_text: Patient John Smith (HSI-5421) underwent a tissue biopsy at the bladder\n collection site. The histopathology report confirmed the presence of cancer in the\n bladder. The tumor, identified as T-BC5421, measures 4 cm in its longest dimension.\n The cancer has been staged as T2, indicating its progression beyond the bladder\n wall. The cancer was asserted on January 10, 2022. The tumor marker test revealed\n elevated levels of urinary bladder tumor antigen (UBTA). John Smith, a Caucasian\n male born on April 15, 1975, is non-Hispanic and resides in zip code 90210. He is\n still alive, with no reported death date at this time. For any further information,\n please contact John Smith at [email protected] or (555) 123-4567.\nraw_completion_output: |-\n human_specimen_identifier: HSI-5421\n human_specimen_collection_site: bladder\n human_specimen_specimen_type: tissue biopsy\n name: John Smith\n contact_info: [email protected] or (555) 123-4567\n birth_date: April 15, 1975\n gender: male\n zip_code: 90210\n us_core_race: Caucasian\n us_core_birth_sex: male\n us_core_ethnicity: non-Hispanic\n death_date: N/A (no reported death date)\n disease_status_evidence_type: histopathology report\n tumor_identifier: T-BC5421\n tumor_body_location: bladder\n tumor_size_longest_dimension: 4 cm\n cancer_stage_stage_type: T2\n cancer_asserted_date: January 10, 2022\n cancer_body_site: bladder\n tumor_marker_test_result_value: elevated levels of urinary bladder tumor antigen (UBTA)\n\n people_human_specimen_identifier_interaction: John Smith\n people_human_specimen_collection_site_interaction: bladder\n people_human_specimen_specimen_type_interaction: tissue biopsy\n people_name_interaction: John Smith\n people_contact_info_interaction: [email protected] or (555) 123-4567\n people_birth_dat""" | |
output = output.replace('\\n', '\n') | |
#### 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"{output}" | |
# Define 5 text input boxes with labels | |
input_boxes = [ | |
gr.inputs.Textbox(label="openai api key"), | |
gr.inputs.Textbox(label="Input data"), | |
] | |
iface = gr.Interface(fn=greet, inputs=input_boxes, outputs="text") | |
iface.launch() | |