Spaces:
Runtime error
Runtime error
Create app.py
Browse files
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)
|