Spaces:
Runtime error
Runtime error
Commit
·
1cc02e9
1
Parent(s):
0d22405
dia prompt changes, negations removal
Browse files
app.py
CHANGED
@@ -34,7 +34,8 @@ def prompt_creation_icd(clean_text):
|
|
34 |
return prompt
|
35 |
|
36 |
def prompt_creation_dia(clean_text):
|
37 |
-
prompt = '
|
|
|
38 |
return prompt
|
39 |
|
40 |
def get_result(text):
|
@@ -43,9 +44,11 @@ def get_result(text):
|
|
43 |
try:
|
44 |
response_dia = GPT_answer(prompt_dia)
|
45 |
#creating ICD codes based on found diagnoses
|
46 |
-
|
|
|
|
|
47 |
response_icd = GPT_answer(prompt_icd)
|
48 |
-
answer = '
|
49 |
return answer
|
50 |
except openai.error.InvalidRequestError as e:
|
51 |
# Handle the InvalidRequestError
|
@@ -62,3 +65,5 @@ iface = gr.Interface(
|
|
62 |
outputs=gr.outputs.Textbox(label="Found ICD-10 codes and diagnoses"),
|
63 |
)
|
64 |
iface.launch()
|
|
|
|
|
|
34 |
return prompt
|
35 |
|
36 |
def prompt_creation_dia(clean_text):
|
37 |
+
prompt = " Extract patient's diagnoses from this text:\n"+clean_text+".\n"
|
38 |
+
prompt += "Print each diagnose from the new line."
|
39 |
return prompt
|
40 |
|
41 |
def get_result(text):
|
|
|
44 |
try:
|
45 |
response_dia = GPT_answer(prompt_dia)
|
46 |
#creating ICD codes based on found diagnoses
|
47 |
+
diagnoses = response_dia.lower().split('\n')
|
48 |
+
diagnoses_cleaned = "\n".join([dia for dia in diagnoses if 'kein' not in dia])
|
49 |
+
prompt_icd = prompt_creation_icd(diagnoses_cleaned)
|
50 |
response_icd = GPT_answer(prompt_icd)
|
51 |
+
answer = 'Found DIAGNOSES:\n'+re.sub('\n', '', diagnoses_cleaned)+'\nICD-10 CODES:\n'+re.sub('\n', '', response_icd)
|
52 |
return answer
|
53 |
except openai.error.InvalidRequestError as e:
|
54 |
# Handle the InvalidRequestError
|
|
|
65 |
outputs=gr.outputs.Textbox(label="Found ICD-10 codes and diagnoses"),
|
66 |
)
|
67 |
iface.launch()
|
68 |
+
|
69 |
+
#%%
|