updates on the agent

This commit is contained in:
2026-09-22 15:29:39 +05:30
parent 90cdb57a38
commit 7227d2d2bd
7 changed files with 522 additions and 20 deletions

View File

@@ -0,0 +1,72 @@
"""
Order Intake Skill - Validates and stages single/bulk order creation.
Integrates with ToolRegistry and AskQuestionTool for missing details.
"""
from typing import Dict, Any, List, Optional
from core.tool_registry import Tool, ToolParameter, register_tool, tool_registry
from core.interactive_question import question_manager
from core.http_client import api_post
from config.system_config import GO_API_BASE_URL
from core.logger import logger
@register_tool(
name="order_intake_skill",
description="Validates and stages new delivery orders. Asks clarifying questions if customer, address, or service is missing.",
parameters=[
ToolParameter(name="customer_name", type="string", description="Name of the customer receiving delivery", required=False),
ToolParameter(name="customer_phone", type="string", description="10-digit phone number of customer", required=False),
ToolParameter(name="delivery_address", type="string", description="Drop-off address or landmark", required=False),
ToolParameter(name="service_option", type="string", description="Delivery speed (e.g. Normal, Express)", required=False, default="Normal"),
],
category="logistics_operations",
)
async def order_intake_skill(
customer_name: Optional[str] = None,
customer_phone: Optional[str] = None,
delivery_address: Optional[str] = None,
service_option: str = "Normal",
) -> Dict[str, Any]:
# Check for missing fields and trigger question if needed
missing = []
if not customer_name:
missing.append("customer name")
if not customer_phone:
missing.append("customer phone")
if not delivery_address:
missing.append("delivery address")
if missing:
q = question_manager.create_question(
prompt=f"To create this order, please provide the {', '.join(missing)}:",
options=[
{"id": "use_recent_customer", "label": "Select from recent customers", "badge": "Quick Fill"},
{"id": "manual_entry", "label": "Type address & phone directly", "badge": "Custom"},
],
allow_custom_input=True,
)
return {
"status": "question_asked",
"question": q.to_dict(),
"partial_draft": {
"customer_name": customer_name,
"customer_phone": customer_phone,
"delivery_address": delivery_address,
"service_option": service_option,
}
}
# All fields present, prepare order stage
payload = {
"customer_name": customer_name,
"customer_phone": customer_phone,
"delivery_address": delivery_address,
"service_option": service_option,
"stage": "ready_for_confirmation",
}
return {
"status": "success",
"action": "confirm_order",
"draft": payload,
"summary": f"Order for {customer_name} ({customer_phone}) to {delivery_address} ready to create."
}

View File

@@ -0,0 +1,43 @@
"""
Repeat Run Skill - Scans prior day/week orders, dedupes against today, and stages repeated runs.
"""
from typing import Dict, Any, List, Optional
from core.tool_registry import Tool, ToolParameter, register_tool
from core.interactive_question import question_manager
from core.logger import logger
@register_tool(
name="repeat_run_skill",
description="Repeat orders from a previous day (yesterday, last Friday, or custom date) with duplicate prevention.",
parameters=[
ToolParameter(name="target_day", type="string", description="Day to repeat (e.g. yesterday, 2026-09-18)", required=False),
ToolParameter(name="tenant_id", type="string", description="Optional tenant filter", required=False),
],
category="logistics_operations",
)
async def repeat_run_skill(
target_day: Optional[str] = None,
tenant_id: Optional[str] = None,
) -> Dict[str, Any]:
if not target_day:
q = question_manager.create_question(
prompt="Which day’s orders would you like to repeat?",
options=[
{"id": "yesterday", "label": "Yesterday’s Orders", "badge": "Most Common"},
{"id": "last_friday", "label": "Last Friday", "badge": "Weekend Wave"},
{"id": "two_days_ago", "label": "2 Days Ago", "badge": "Prior Run"},
],
allow_custom_input=True,
)
return {
"status": "question_asked",
"question": q.to_dict(),
}
return {
"status": "success",
"action": "stage_repeat_run",
"target_day": target_day,
"summary": f"Scanning past orders for {target_day} to build repeat dispatch batch."
}