diff --git a/README.md b/README.md index 333524c..848c539 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,19 @@ percentage, missing keywords, and profile summary. from the database. - Utilizes a Cohere ReAct Agent to process user queries and generate responses. +### 23. MediGem: Medical Diagnosis AI Assistant + +- **Route:** `/MediGem` +- **Description:** This API endpoint leverages the New Google Gemini AI Model to analyze medical images and identify potential health conditions. +- **Feature:** + - **Upload a Medical Image:** Users can upload a medical image in JPEG format for analysis. + - **AI Analysis:** The AI model examines the image to identify anomalies, diseases, or health issues. + - **Findings Report:** Documents observed anomalies or signs of disease in a structured format. + - **Recommendations:** Suggests potential next steps, including further tests or treatments. + - **Treatment Suggestions:** Recommends possible treatment options or interventions if applicable. + - **Image Quality Note:** Indicates if certain aspects are 'Unable to be determined based on the provided image.' + - **Disclaimer:** Includes the disclaimer: "Consult with a Doctor before making any decisions." + ## Usage Each endpoint accepts specific parameters as described in the respective endpoint documentation. Users can make POST requests to these endpoints with the required parameters to perform the desired tasks. diff --git a/api.py b/api.py index b86fc62..ed396b9 100644 --- a/api.py +++ b/api.py @@ -717,6 +717,26 @@ async def query_db(database: UploadFile = File(...), prompt: str = Form(...)): finally: database.file.close() + +@app.post("/MediGem",description="Medical Diagnosis AI Assistant") +async def medigem(image_file: UploadFile = File(...)): + + image = image_file.file.read() + image_parts = [{ + "mime_type": "image/jpeg", + "data": image + }] + model = genai.GenerativeModel(settings.GEMINI_PRO_1_5) + response = model.generate_content([image_parts[0], settings.MEDI_GEM_PROMPT]) + db = MongoDB() + payload = { + "endpoint" : "/MediGem", + "output" : response.text + } + mongo_data = {"Document": payload} + result = db.insert_data(mongo_data) + print(result) + return ResponseText(response=remove_substrings(response.text)) if __name__ == '__main__': import uvicorn diff --git a/settings.py b/settings.py index 3612d39..03c38c8 100644 --- a/settings.py +++ b/settings.py @@ -119,4 +119,26 @@ Here is information about the database: {schema_info} - """ \ No newline at end of file + """ + +MEDI_GEM_PROMPT = """ + As a highly skilled medical practitioner specializing in image analysis, you are tasked with examining medical images for a renowned hospital. + Your expertise is crucial in identifying any anomalies,diseases, or health issues that may be present in the image. + + Your Responsibilities include: + + 1. Detailed Analysis: Thoroughly analyze each image, focusing on identifying any abnormal findings. + 2. Findings Report: Document all the observed anomalies or signs of disease. Clearly articulate these findings in structured format. + 3. Recommendations and Next Steps: Based on your analysis, suggest potential next steps. including further tests or treatments as applicable. + 4. Treatment Suggestions: If appropriate, recommend possible treatment options or interventions. + + Important Notes: + + 1. Scope of Response: Only respond if the image pertains to human health issues. + 2. Clarity of Image: In cases where the image quality impedes clear analysis, note that certain aspects are 'Unable to be determined based on the provided image.' + 3. Disclaimer: Accompany your analysis with the disclaimer: "Consult with a Doctor before making any decisions." + 4.Your insights are invaluable in guiding clinical decisions. Please proceed with analysis, adhering to the structured approach outlined above. + + Please provide me an output with these 4 headings Detailed Analysis, Findings Report, Recommendations and Next Steps and Treatment Suggestions. + + """ \ No newline at end of file