Skip to content

Commit

Permalink
ADDED: MediGem
Browse files Browse the repository at this point in the history
  • Loading branch information
AquibPy committed Jun 12, 2024
1 parent a69b134 commit e81b498
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 20 additions & 0 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 23 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,26 @@
Here is information about the database:
{schema_info}
"""
"""

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.
"""

0 comments on commit e81b498

Please sign in to comment.