Spaces:
Sleeping
Sleeping
File size: 1,021 Bytes
fb38df2 83fe4f9 fb38df2 83fe4f9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | from backend.ai.client import llm_client, render_prompt
from backend.ai.prompts import CLASSIFY_PROMPT
def classify_email(from_email: str, subject: str, body: str, business_context: str) -> dict:
if llm_client.is_ready():
return llm_client.generate_json(
render_prompt(
CLASSIFY_PROMPT,
categories="order, availability_inquiry, complaint, greeting, other",
from_email=from_email,
subject=subject,
body=body,
business_context=business_context,
)
)
text = f"{subject} {body}".lower()
category = "order" if "order" in text else "availability_inquiry" if "available" in text else "other"
priority = "high" if "restaurant" in from_email.lower() else "medium"
return {
"category": category,
"priority": priority,
"requires_response": True,
"sentiment": "neutral",
"reasoning": "Derived from keywords and sender profile.",
}
|