import os, json, re
from google import genai
def run(email_text: str) -> dict:
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
response = client.models.generate_content(
model="gemini-2.0-flash",
contents=f"""Classify this email intent.
Return JSON: {{"intent": "interested|counter_offer|rejection|unclear", "confidence": 0.0-1.0, "summary": "one sentence"}}
Email: {email_text}
Return ONLY valid JSON."""
)
cleaned = re.sub(r'```json\s*|\s*```', '', response.text).strip()
return json.loads(cleaned)