process_medical_record:v3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import weave
from typing import Dict
def format_dialogue(dialogue: str):
dialogue = dialogue.replace("\n", " ")
transcript = f"Dialogue: {dialogue}"
return transcript
medical_task = "\nExtract details from the medical records:\n\n{transcript}\n"
client = "<openai.OpenAI object at 0x125810810>"
medical_system_prompt = "\nYou're a medical assistant AI that helps extract important info from patient records. Make sure to keep patient info private and follow the format asked for in the prompt. Be clear and to the point.\n"
@weave.op()
def process_medical_record(dialogue: str) -> Dict:
transcript = format_dialogue(dialogue)
prompt = medical_task.format(transcript=transcript)
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": medical_system_prompt},
{"role": "user", "content": prompt},
],