from pydantic import BaseModel, Field
from typing import List, Optional, Any
from typing_extensions import Literal


class ProductSchema(BaseModel):
    product_id: Optional[str] = Field(
        None, description="Unique identifier of the product (optional)."
    )
    currency: Optional[str] = Field(
        None, description="Currency of the price, e.g., 'INR', 'USD'."
    )
    price: Optional[str] = Field(
        None, description="Price of the product, e.g., '₹999'."
    )
    description: Optional[str] = Field(
        None, description="Text description of the product."
    )
    image_url: Optional[str] = Field(None, description="URL to the product image.")
    title: Optional[str] = Field(None, description="Name or title of the product.")


class SalesOutputSchema(BaseModel):
    query: str = Field(
        ..., description="Search term or item name, e.g. 'baby girl dresses'."
    )
    # context: str = Field(
    #     ...,
    #     description="Filters or preferences: price range, color, sort order, etc., e.g. 'under 40, pink, sorted by popularity'.",
    # )
    answer: str = Field(
        ...,
        description="Natural language summary of the tool results, highlighting key features, styles, price range, and suitability",
    )
    satisfied_output: bool = Field(
        ...,
        description="Indicates whether the response fully satisfies the user's request (True or False).",
    )
    product_ids: List[str] = Field(
        ..., description="List of product IDs relevant to the search results."
    )
    # products: Optional[List[ProductSchema]] = Field(
    #     default_factory=list, description="List of recommended products."
    # )


class TRIAGE_ROUTER_SCHEMA(BaseModel):
    classification: Literal["ecommerce", "rag", "general"] = Field(
        ..., description="The classification of the query."
    )
    optimized_query: str = Field(
        ...,
        description="The optimized or reformulated query for downstream processing.",
    )
    answer: str = Field(
        ...,
        description="The final answer generated for the query, based on reasoning and classification.",
    )
    conversation_context: str = Field(
        ...,
        description="Relevant context from the ongoing conversation history, including user preferences, constraints, or previously mentioned products/attributes.",
    )


class ShopifySupervisorRouter(BaseModel):
    """Classify and route queries for Shopify workflow."""

    classification: Literal["orderagent", "recommendation_agent", "humanagent","general", "rag_agent"] = Field(
        description="Route query to orderagent, recommendation_agent, or HumanAgent (for user dissatisfaction or explicit human requests). Queries that don't match are handled as general responses."
    )
    general: Optional[str] = Field(
        description="Answer/description for general queries that don't match any specific agent.",
    )
