Spaces:
Sleeping
Sleeping
| from google import genai | |
| from app.config import settings | |
| # ✅ Correct way to init client with API key | |
| client = genai.Client(api_key=settings.GEMINI_API_KEY) | |
| def extract_with_prompt(report_text: str, system_prompt: str, model_name="gemini-2.5-flash"): | |
| if not report_text: | |
| return {"status": 404, "message": "Empty report"} | |
| try: | |
| response = client.models.generate_content( | |
| model=model_name, | |
| contents=report_text, | |
| config={"system_instruction": system_prompt} | |
| ) | |
| if not response.text or "NULL" in response.text.upper(): | |
| return {"status": 404, "message": "No medical data found"} | |
| return {"status": 200, "message": response.text.strip()} | |
| except Exception as e: | |
| return {"status": 500, "message": f"Error: {str(e)}"} | |