paopaoka3325 commited on
Commit
5a5912b
·
1 Parent(s): 87ccf2e

Add application files

Browse files
Files changed (1) hide show
  1. app.py +3 -66
app.py CHANGED
@@ -19,7 +19,7 @@ def greet(name1, name2):
19
  str3_huggingface = "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" # huggingface
20
  str4_input = name2
21
 
22
- '''
23
  with open('abstractsave.txt', 'w') as f:
24
  f.write(str4_input)
25
 
@@ -70,79 +70,16 @@ def greet(name1, name2):
70
 
71
  # Convert the key-value pairs into a table format (a list of lists)
72
  df_pred = pd.DataFrame(key_value_pairs, columns = ["Ontology Attribute", "Value"]).iloc[:19,:]
73
- '''
74
-
75
- # Generate a DataFrame with 50 rows and 2 columns filled with random numbers
76
- num_rows = 50
77
- num_cols = 2
78
- import numpy as np
79
- data = np.random.rand(num_rows, num_cols)
80
-
81
- # Create a DataFrame
82
- df_pred = pd.DataFrame(data, columns=['Column1', 'Column2'])
83
 
84
  html_output = df_pred.to_html()
85
 
86
- # Add an id to the HTML table for reference in the JavaScript function
87
- html_output = html_output.replace("<table ", "<table id='output-table' ")
88
-
89
  # Save the CSV data to a temporary file
90
  with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as temp_file:
91
  df_pred.to_csv(temp_file.name, index=False)
92
  csv_output = temp_file.name
93
 
94
- # Create a button to toggle table view and a script to handle the button click
95
- # Create a button to toggle table view and a script to handle the button click
96
- show_more_button = """
97
- <button onclick="toggleTableView()">Show More</button>
98
- <script>
99
- var isFullTableShown = false;
100
- function toggleTableView() {
101
- console.log('toggleTableView function called'); // Debugging line
102
- var table = document.getElementById('output-table');
103
- var rows = table.getElementsByTagName('tr');
104
- console.log('Number of rows in table: ' + rows.length); // Debugging line
105
- for (var i = 16; i < rows.length; i++) {
106
- if (isFullTableShown) {
107
- rows[i].style.display = 'none';
108
- } else {
109
- rows[i].style.display = '';
110
- }
111
- }
112
- isFullTableShown = !isFullTableShown;
113
- console.log('isFullTableShown status: ' + isFullTableShown); // Debugging line
114
- document.querySelector('button').textContent = isFullTableShown ? 'Show Less' : 'Show More';
115
- }
116
- </script>
117
- """
118
-
119
- # Initial CSS to hide rows beyond the 15th
120
- initial_css = """
121
- <style>
122
- #output-table tr:nth-child(n+16) {
123
- display: none;
124
- }
125
- </style>
126
- """
127
- # ... previous code ...
128
-
129
- # Combine the initial CSS, HTML table, and the Show More button
130
- html_output = initial_css + html_output + show_more_button
131
-
132
  return html_output, csv_output
133
- # return df_pred.to_html()
134
-
135
- #### output_string1, error_string1=run_command("poetry")# ontogpt")
136
 
137
-
138
- # return location
139
- # For the purpose of this example, I'm just returning the values concatenated
140
- # return f"Inputs received: {str1} \n, {str2}, {str3}, {str4}, '--------------', '--------------', {output_string1},{error_string1},{output_string2},{error_string2},{output}"
141
- # # return location
142
- # For the purpose of this example, I'm just returning the values concatenated
143
- # return f"{str4_input}"
144
-
145
- # Define 5 text input boxes with labels
146
  input_boxes = [
147
  gr.inputs.Textbox(label="openai api key"),
148
  gr.inputs.Textbox(lines=20, label="Input cencer report", placeholder='Type text here...'),
@@ -153,7 +90,7 @@ disclaimer = (
153
  "If you need support, please contact us at https://mcodegpt.org/"
154
  )
155
 
156
- # iface = gr.Interface(fn=greet, inputs=input_boxes, outputs="text")
157
  iface = gr.Interface(fn=greet,
158
  inputs=input_boxes,
159
  outputs=[
@@ -161,7 +98,7 @@ iface = gr.Interface(fn=greet,
161
  gr.outputs.File(label="Download Output as CSV")
162
  ],
163
 
164
- examples=[ # Sample text examples
165
  ["87uigiyyu&979890909nY9j87y8n78 (replace with your own OpenAI key)", "Patient John Smith (HSI-5421) underwent a tissue biopsy at the bladder collection site. The histopathology report confirmed the presence of cancer in the bladder. The tumor, identified as T-BC5421, measures 4 cm in its longest dimension. The cancer has been staged as T2, indicating its progression beyond the bladder wall. The cancer was asserted on January 10, 2022. The tumor marker test revealed elevated levels of urinary bladder tumor antigen (UBTA). John Smith, a Caucasian male born on April 15, 1975, is non-Hispanic and resides in zip code 90210. He is still alive, with no reported death date at this time. For any further information, please contact John Smith at [email protected] or (555) 123-4567." ],
166
  ["87uigiyyu&979890909nY9j87y8n78 (replace with your own OpenAI key)", "Patient CS1256, Emma Thompson, is a 42-year-old non-Hispanic white female with a biopsy specimen collected from the cervix. The pathology report indicates the presence of a tumor with an identified tumor identifier, T123456, located in the cervix. The tumor has a longest dimension of 2.3 cm. Based on the staging, the cancer is classified as Stage IA. The cancer was asserted on March 10, 2020. The tumor marker test result for CA-125 is 32 U/mL. Further evaluation and treatment options will be discussed with the patient. For any inquiries or updates, please contact Emma Thompson at [email protected] or (555) 123-4567."],
167
  ["87uigiyyu&979890909nY9j87y8n78 (replace with your own OpenAI key)", "This cancer report is for patient Emily Johnson (HS123456), a 43-year-old white female residing in zip code 12345. The patient underwent a tissue biopsy at Memorial Hospital to collect the human specimen. The tumor identified as T12345 is located in the femur, with a size of 10 cm in its longest dimension. The cancer stage is classified as Stage III, and the cancer was asserted on June 5, 2021. The body site affected by the cancer is the bones and joints. The disease status evidence is based on an MRI scan. Additionally, the tumor marker test revealed elevated levels of alkaline phosphatase. As of now, the patient is still alive, and no death date has been recorded. For further communication, Emily Johnson can be reached at 555-1234 or [email protected]."],
 
19
  str3_huggingface = "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" # huggingface
20
  str4_input = name2
21
 
22
+
23
  with open('abstractsave.txt', 'w') as f:
24
  f.write(str4_input)
25
 
 
70
 
71
  # Convert the key-value pairs into a table format (a list of lists)
72
  df_pred = pd.DataFrame(key_value_pairs, columns = ["Ontology Attribute", "Value"]).iloc[:19,:]
 
 
 
 
 
 
 
 
 
 
73
 
74
  html_output = df_pred.to_html()
75
 
 
 
 
76
  # Save the CSV data to a temporary file
77
  with tempfile.NamedTemporaryFile(delete=False, suffix=".csv") as temp_file:
78
  df_pred.to_csv(temp_file.name, index=False)
79
  csv_output = temp_file.name
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  return html_output, csv_output
 
 
 
82
 
 
 
 
 
 
 
 
 
 
83
  input_boxes = [
84
  gr.inputs.Textbox(label="openai api key"),
85
  gr.inputs.Textbox(lines=20, label="Input cencer report", placeholder='Type text here...'),
 
90
  "If you need support, please contact us at https://mcodegpt.org/"
91
  )
92
 
93
+
94
  iface = gr.Interface(fn=greet,
95
  inputs=input_boxes,
96
  outputs=[
 
98
  gr.outputs.File(label="Download Output as CSV")
99
  ],
100
 
101
+ examples=[
102
  ["87uigiyyu&979890909nY9j87y8n78 (replace with your own OpenAI key)", "Patient John Smith (HSI-5421) underwent a tissue biopsy at the bladder collection site. The histopathology report confirmed the presence of cancer in the bladder. The tumor, identified as T-BC5421, measures 4 cm in its longest dimension. The cancer has been staged as T2, indicating its progression beyond the bladder wall. The cancer was asserted on January 10, 2022. The tumor marker test revealed elevated levels of urinary bladder tumor antigen (UBTA). John Smith, a Caucasian male born on April 15, 1975, is non-Hispanic and resides in zip code 90210. He is still alive, with no reported death date at this time. For any further information, please contact John Smith at [email protected] or (555) 123-4567." ],
103
  ["87uigiyyu&979890909nY9j87y8n78 (replace with your own OpenAI key)", "Patient CS1256, Emma Thompson, is a 42-year-old non-Hispanic white female with a biopsy specimen collected from the cervix. The pathology report indicates the presence of a tumor with an identified tumor identifier, T123456, located in the cervix. The tumor has a longest dimension of 2.3 cm. Based on the staging, the cancer is classified as Stage IA. The cancer was asserted on March 10, 2020. The tumor marker test result for CA-125 is 32 U/mL. Further evaluation and treatment options will be discussed with the patient. For any inquiries or updates, please contact Emma Thompson at [email protected] or (555) 123-4567."],
104
  ["87uigiyyu&979890909nY9j87y8n78 (replace with your own OpenAI key)", "This cancer report is for patient Emily Johnson (HS123456), a 43-year-old white female residing in zip code 12345. The patient underwent a tissue biopsy at Memorial Hospital to collect the human specimen. The tumor identified as T12345 is located in the femur, with a size of 10 cm in its longest dimension. The cancer stage is classified as Stage III, and the cancer was asserted on June 5, 2021. The body site affected by the cancer is the bones and joints. The disease status evidence is based on an MRI scan. Additionally, the tumor marker test revealed elevated levels of alkaline phosphatase. As of now, the patient is still alive, and no death date has been recorded. For further communication, Emily Johnson can be reached at 555-1234 or [email protected]."],