from typing import Optional, Any, Literal
from pydantic import BaseModel, Field
from typing import List, Dict, Any, Optional, Union,TypedDict

class ShopifyCreds(TypedDict):
    access_token: str
    shop_domain: str

class AgentRequest(BaseModel):
    text: str = Field(..., description="User query text")
    chat_id: str = Field(..., description="Unique chat session ID")
    user_id: str | None = Field(None, description="Authenticated user ID")
    user_name: str | None = Field(None, description="User's name")
    user_email: str | None = Field(None, description="User's email")
    shopify_creds: Optional[ShopifyCreds] = Field(None, description="Shopify client instance")
    type: Literal["AIAgent", "HumanAgent"] = "AIAgent"

class AgentProductResponse(BaseModel):
    answer: str = Field(..., description="Natural language summary for the user")
    product_ids: List[str] = Field(
        None, description="List of product IDs suitable with the query"
    )


class QueryArgs(BaseModel):
    flt: Optional[Union[Dict[str, Any], str]] = None
    limit: int = Field(10, description="Max products to return")
    sort: Optional[Union[Dict[str, int], str]] = None


class RetrievalArgs(BaseModel):
    query: str = Field(
        ..., description="Natural language query to search the product catalog"
    )


class RAGArgs(BaseModel):
    query: str = Field(
        ..., description="Natural language query to search the RAG Document"
    )
