o
    @Tj                     @   st   d Z ddlmZmZ ddlmZ G dd deZG dd deZG dd	 d	eZG d
d deZ	G dd deZ
dS )z&Abstract base class for LLM providers.    )ABCabstractmethod)	BaseModelc                   @   sJ   e Zd ZU dZeed< dZedB ed< dZedB ed< dZe	dB ed< dS )GarmentAnalysisz(Single garment analysis result from LLM.category_mainNcategory_subdescriptiontags)
__name__
__module____qualname____doc__str__annotations__r   r   r	   dict r   r   5/home/ubuntu/htdocs/ootd-api/app/services/llm/base.pyr      s   
 r   c                   @   s"   e Zd ZU dZeed< eed< dS )StyleCategoryScorez.Score and comment for a single style category.scorecommentN)r
   r   r   r   intr   r   r   r   r   r   r      s   
 r   c                   @   sF   e Zd ZU dZeed< eed< eed< eed< eed< ee ed< dS )	StyleAnalysisz.Overall outfit style analysis result from LLM.color_palette
silhouettedetailoverall_scoreoverall_comment
style_tagsN)	r
   r   r   r   r   r   floatr   listr   r   r   r   r      s   
 r   c                   @   s:   e Zd ZU dZeed< eed< eed< eed< eed< dS )StyleAnalysisTempz4Context-aware outfit style analysis result from LLM.time_contextoccasion_contextweather_contextcolor_harmonyimprovement_tipsN)r
   r   r   r   r   r   r   r   r   r   r    #   s   
 r    c                   @   s   e Zd ZdZededee fddZe	ddedede	d	e	dB dedB f
d
dZ
ededefddZededefddZe	ddedee dee	 d	e	dB deedB e	dB f f
ddZdS )BaseLLMProviderz0Interface that all LLM providers must implement.imagereturnc                       dS )zAnalyze image and return detected garments with categories, tags, description.

        Args:
            image: Raw image bytes (JPEG/PNG).

        Returns:
            List of GarmentAnalysis for each detected garment.
        Nr   selfr'   r   r   r   analyze_garment0      
zBaseLLMProvider.analyze_garmentNitemmodeimage_modelc                    r)   )u  Generate ghost mannequin image for a garment.

        Args:
            image: Original image bytes.
            item: Analysis result for the target garment.
            mode: "edit" (remove person) or "generate" (new image from description).
            image_model: Optional image-generation model override. ``None`` →
                provider default. The Gemini provider ignores this.

        Returns:
            Generated image bytes, or None on failure.
        Nr   )r+   r'   r.   r/   r0   r   r   r   generate_ghost_mannequin<   s   z(BaseLLMProvider.generate_ghost_mannequinc                    r)   )zAnalyze overall outfit style from image.

        Args:
            image: Raw image bytes (JPEG/PNG).

        Returns:
            StyleAnalysis with scores, comments, and style tags.
        Nr   r*   r   r   r   analyze_styleR   r-   zBaseLLMProvider.analyze_stylec                    r)   )zContext-aware outfit style analysis (time/occasion/weather).

        Args:
            image: Raw image bytes (JPEG/PNG).

        Returns:
            StyleAnalysisTemp with 5 contextual sections.
        Nr   r*   r   r   r   analyze_style_temp^   r-   z"BaseLLMProvider.analyze_style_tempperson_imageghost_images
categoriesc                    r)   )u0  Composite ghost garments onto a person via multi-image generation.

        Args:
            person_image: Raw person photo bytes (JPEG).
            ghost_images: List of isolated garment (ghost mannequin) PNG bytes,
                ordered 1..N — the prompt references them as "#N".
            categories: Parallel list of ``category_main`` strings
                (``"top" | "bottom" | "outer" | "dress"``) used by the prompt
                to let the LLM decide which garments are bottoms
                (to be skipped when only the upper body is visible).
            image_model: Optional image-generation model override. ``None`` →
                provider default. The Gemini provider ignores this.

        Returns:
            Tuple ``(image_bytes, llm_note)``.

            - ``image_bytes`` — composited PNG bytes, or ``None`` on failure.
            - ``llm_note`` — a short English sentence the model returned
              alongside the image (e.g. ``"Skipped #2 because ..."``), or
              ``None`` if the model returned no text.
        Nr   )r+   r4   r5   r6   r0   r   r   r   generate_vtonj   s   zBaseLLMProvider.generate_vton)N)r
   r   r   r   r   bytesr   r   r,   r   r1   r   r2   r    r3   tupler7   r   r   r   r   r&   -   sD    r&   N)r   abcr   r   pydanticr   r   r   r   r    r&   r   r   r   r   <module>   s    	
