Shreyas45 commited on
Commit
98a159a
·
verified ·
1 Parent(s): bbbbdf5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+
3
+ openai.api_key = "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"
4
+
5
+ def convert_text_to_structured(text):
6
+ prompt = f"Unstructured medical notes:\n\"{text}\"\nStructured format:\n1. Patient Information:\n2. Chief Complaint:\n3. Medical History:\n4. Physical Examination Findings:\n5. Diagnostic Tests:\n6. Diagnosis:\n7. Treatment:\n8. Disposition:\n"
7
+
8
+ response = openai.Completion.create(
9
+ engine="gpt-3.5-turbo-instruct",
10
+ prompt=prompt,
11
+ max_tokens=300
12
+ )
13
+
14
+ structured_data = response["choices"][0]["text"]
15
+ return structured_data
16
+
17
+ import gradio as gr
18
+
19
+ def convert_text(input_text):
20
+ return convert_text_to_structured(input_text)
21
+
22
+ iface = gr.Interface(fn=convert_text, inputs="text", outputs="text")
23
+ iface.launch(share=True)