Spaces:
Sleeping
Sleeping
| import json | |
| from backend.ai.client import llm_client, render_prompt | |
| from backend.ai.prompts import COMPOSE_PROMPT | |
| def compose_reply(context: dict, tone: str = "friendly") -> str: | |
| if llm_client.is_ready(): | |
| return llm_client.generate_text( | |
| render_prompt( | |
| COMPOSE_PROMPT, | |
| business_name=context.get("business_name", "FlowPilot customer"), | |
| business_type=context.get("business_type", "small business"), | |
| owner_name=context.get("owner_name", "Raj"), | |
| tone=tone, | |
| context=json.dumps(context, indent=2), | |
| data=json.dumps(context, indent=2), | |
| ) | |
| ) | |
| customer = context.get("customer_name", "there") | |
| items = context.get("items", []) | |
| item_summary = ", ".join(f"{item['quantity']} x {item['name']}" for item in items) or "your request" | |
| return ( | |
| f"Hi {customer},\n\n" | |
| f"Thanks for your order. We have {item_summary} ready and will follow up with pickup details shortly.\n\n" | |
| "Raj" | |
| ) | |