File size: 786 Bytes
98a159a
85aa07f
98a159a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import openai
import gradio as gr

openai.api_key = "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"

def convert_text_to_structured(text):
    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"

    response = openai.Completion.create(
        engine="gpt-3.5-turbo-instruct",
        prompt=prompt,
        max_tokens=300
    )

    structured_data = response["choices"][0]["text"]
    return structured_data

def convert_text(input_text):
    return convert_text_to_structured(input_text)

iface = gr.Interface(fn=convert_text, inputs="text", outputs="text")
iface.launch(share=True)