import requests from bs4 import BeautifulSoup from openai import OpenAI import base64 from config import openai_api def encode_image(image_path): with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode('utf-8') client = OpenAI(api_key=openai_api) def get_ai_response(prompt_content): response = client.chat.completions.create( model="gpt-4o", messages=[ { "role": "system", "content": [ { "type": "text", "text": f"""You are an experimental AI-copilot for doctors. They will check your outputs You will be given by the doctor patient data input and your role will be to determine the most probable diagnose. You will include all relevant literature backup and references needed and a whole reasoning path of why you think it is. Be very professional and redact as a health practioner. You format each output with only: # Probable diagnose: X #### likelihood: XX% # Suggested treatment: -XX - XX # Full reasoning and path to diagnose (as a clean decision path with all relevant elements) """ } ] }, { "role": "user", "content": prompt_content }, ], temperature=1, max_tokens=1439, top_p=1, frequency_penalty=0, presence_penalty=0, stream=True ) return response def get_answer(patient_data): answer = get_ai_response(patient_data) # answer = "" return answer