Spaces:
Sleeping
Sleeping
Update get_answer.py
Browse files- get_answer.py +5 -24
get_answer.py
CHANGED
|
@@ -11,7 +11,7 @@ def encode_image(image_path):
|
|
| 11 |
|
| 12 |
|
| 13 |
client = OpenAI(api_key=openai_api)
|
| 14 |
-
def get_ai_response(prompt_content):
|
| 15 |
response = client.chat.completions.create(
|
| 16 |
model="gpt-4o",
|
| 17 |
messages=[
|
|
@@ -20,25 +20,7 @@ def get_ai_response(prompt_content):
|
|
| 20 |
"content": [
|
| 21 |
{
|
| 22 |
"type": "text",
|
| 23 |
-
"text":
|
| 24 |
-
You will be given by the doctor patient data input and your role will be to determine the most probable diagnose.
|
| 25 |
-
You will include all relevant literature backup and references needed and a whole reasoning path of why you think it is.
|
| 26 |
-
Be very professional and redact as a health practioner.
|
| 27 |
-
|
| 28 |
-
You format each output with only:
|
| 29 |
-
|
| 30 |
-
# Probable diagnose: X
|
| 31 |
-
|
| 32 |
-
#### likelihood: XX%
|
| 33 |
-
|
| 34 |
-
# Suggested treatment:
|
| 35 |
-
-XX
|
| 36 |
-
- XX
|
| 37 |
-
|
| 38 |
-
# Full reasoning and path to diagnose (as a clean decision path with all relevant elements)
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
"""
|
| 42 |
}
|
| 43 |
]
|
| 44 |
},
|
|
@@ -52,12 +34,11 @@ def get_ai_response(prompt_content):
|
|
| 52 |
top_p=1,
|
| 53 |
frequency_penalty=0,
|
| 54 |
presence_penalty=0,
|
| 55 |
-
stream=True
|
| 56 |
)
|
| 57 |
-
return response
|
| 58 |
|
| 59 |
|
| 60 |
-
def get_answer(patient_data):
|
| 61 |
-
answer = get_ai_response(patient_data)
|
| 62 |
# answer = ""
|
| 63 |
return answer
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
client = OpenAI(api_key=openai_api)
|
| 14 |
+
def get_ai_response(prompt_content, prompt):
|
| 15 |
response = client.chat.completions.create(
|
| 16 |
model="gpt-4o",
|
| 17 |
messages=[
|
|
|
|
| 20 |
"content": [
|
| 21 |
{
|
| 22 |
"type": "text",
|
| 23 |
+
"text": prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
]
|
| 26 |
},
|
|
|
|
| 34 |
top_p=1,
|
| 35 |
frequency_penalty=0,
|
| 36 |
presence_penalty=0,
|
|
|
|
| 37 |
)
|
| 38 |
+
return response.choices[0].message.content
|
| 39 |
|
| 40 |
|
| 41 |
+
def get_answer(patient_data, prompt):
|
| 42 |
+
answer = get_ai_response(patient_data, prompt)
|
| 43 |
# answer = ""
|
| 44 |
return answer
|