from functools import lru_cache from typing import Optional from pydantic_settings import BaseSettings ''' EXTRACT_INFO_SYSTEM = "You are an expert in structured data extraction. You will be given an image or a set of images of a product and should extract its properties into the given structure." EXTRACT_INFO_HUMAN = ( """Output properties of the main product (or {product_taxonomy}) shown in the images. You should use the following product data to assist you, if available: {product_data} If an attribute appears in both the image and the product data, use the value from the product data.""" ).replace(" ", "") FOLLOW_SCHEMA_SYSTEM = "You are an expert in structured data extraction. You will be given an dictionary of attributes of a product and should output the its properties into the given structure." FOLLOW_SCHEMA_HUMAN = """Convert following attributes to structured schema. Keep all the keys and number of values. Only replace the values themselves. : {json_info}""" ''' EXTRACT_INFO_SYSTEM = "You are an expert in structured data extraction. You will be given an image or a set of images of a product and should extract its properties into the given structure." EXTRACT_INFO_STATS = ( """using the schema below while analysing the product in the images, for each attribute, look through the possible outputs, and assign a percentage to each of them, representing how certain you are of that output being the best fit. : {product_data} """ ).replace(" ", "") EXTRACT_INFO_HUMAN = ( """I have a schema for extracting attributes from images of products. It's pasted below. For each of the allowed values, in each of the attributes, assign a percentage of certainty that the product fits with that value. I have attached images of the product. Once you have assigned a certainty to each of the attributes, re-evaluate based on the top three values to make absolutely sure you are selecting the best fit. For the attributes that can have arrays as return, select the best fitting 1-3. If any of the attributes are mentioned in the product data, do not hesitate to leverage that. product data: {product_data} schema = "Length": { "description": "Length of dress. Look for the overall visual of the dress, not just the hem lines", "data_type": "string", "allowed_values": ["Maxi", "Knee Length", "Mini", "Midi"] }, "Style": { "description": "Select the most appropriate dress style based on the garment's silhouette, fit, structural features, and overall design. Focus on how the dress is constructed and worn: whether it is fitted or loose, whether it has defining elements such as shirring, boning, buttons, collars, tiers, layering, or wrap ties. Ignore color, pattern, or fabric unless they directly influence the structure (e.g., stretch fabric for Bodycon). Use the visual cues of the neckline, sleeves, waistline, hemline, and closure type to guide your choice. For example, the placement on the body of the waistline is very important. Only select one style that best captures the dominant structural or design identity of the dress. Refer to the following definitions when uncertain: - 'A Line': Fitted at the top and gradually flares toward the hem, forming an 'A' shape. - 'Bodycon': Tight-fitting and figure-hugging, usually made with stretchy fabric. - 'Column': Straight silhouette from top to bottom, with minimal shaping or flare. - 'Shirt Dress': Structured like a shirt with buttons, collar, and sleeves; may include a belt. - 'Wrap Dress': Features a front closure that wraps and ties at the side or back. - 'Slip': Lightweight, spaghetti-strap dress with minimal structure, often bias-cut. - 'Kaftan': Very loose, flowing garment with wide sleeves and minimal shaping. - 'Smock': Loose-fitting with gathered or shirred sections (usually bodice or neckline). - 'Corset': Structured bodice with boning or lacing that shapes the waist. - 'Pinafore': Sleeveless over-dress, often worn layered over another top. - 'Jumper Dress': Layered dress style similar to a pinafore, often more casual or thick-strapped. - 'Blazer Dress': Tailored like a blazer or suit jacket, often double-breasted or lapelled. - 'Tunic': Loose and straight-cut, often worn short or over pants/leggings. - 'Gown': Full-length, formal dress with a structured or dramatic silhouette. - 'Asymmetric': Dress with a non-symmetrical hem, neckline, or sleeve design. - 'Shift': Simple, straight dress with no defined waist, typically above the knee. - 'Drop waist': Waistline sits low on the hips, usually with a loose top and flared skirt. - 'Empire': High waistline just below the bust, flowing skirt from there downward. - 'Modest': Covers most of the body, with high neckline, long sleeves, and longer hemline. Use structural cues over stylistic interpretation. Do not infer intent (e.g., party, formal) unless it’s directly tied to the construction. ", "data_type": "string", "allowed_values": [ "A Line","Bodycon","Column","Shirt Dress","Wrap Dress","Slip","Kaftan","Smock","Corset","Pinafore","Jumper Dress","Blazer Dress","Tunic","Gown","Asymmetric","Shift","Drop waist","Empire","Modest"] }, "Sleeve_length": { "description": "Length of sleeves on dress", "data_type": "string", "allowed_values": [ "Sleeveless","Three quarters Sleeve","Long Sleeve","Short Sleeve","Strapless"] }, "Neckline": { "description": "Identify the neckline style based on the visible shape and structure of the neckline area. Focus on the cut and contour around the collarbone, shoulders, and upper chest. Only choose the neckline that best represents the dominant design — ignore collars, patterns, or styling details unless they significantly alter the neckline shape. Use the following definitions for clarity: - 'V Neck': Neckline dips down in the shape of a 'V', varying from shallow to deep. - 'Sweetheart': A heart-shaped neckline, often curving over the bust and dipping in the center. - 'Round Neck': Circular neckline sitting around the base of the neck, not as high as a crew neck. - 'Halter Neck': Straps go around the neck, leaving shoulders and upper back exposed. - 'Square Neck': Straight horizontal cut across the chest with vertical sides, forming a square. - 'High Neck': Extends up the neck slightly but not folded like a turtle neck. - 'Crew Neck': High, rounded neckline that sits close to the neck (commonly found in T-shirts). - 'Cowl Neck': Draped or folded neckline that hangs in soft folds. - 'Turtle Neck': High neckline that folds over and covers the neck completely. - 'Off the Shoulder': Sits below the shoulders, exposing the shoulders and collarbone. - 'One Shoulder': Covers one shoulder only, leaving the other bare. - 'Bandeau': Straight, strapless neckline that wraps across the bust. - 'Boat Neck': Wide, shallow neckline that runs almost horizontally from shoulder to shoulder. - 'Scoop Neck': U-shaped neckline, typically deeper than a round neck. - Always prioritize structure over styling — for example, a dress with embellishment or a mesh overlay still counts as 'V Neck' if the main shape is a V. If a neckline is borderline between two types, choose the simpler or more dominant structure.", "data_type": "string", "allowed_values": [ "V Neck","Sweetheart","Round Neck","Halter Neck","Square Neck","High Neck","Crew Neck","Cowl Neck","Turtle Neck","Off the shoulder","One Shoulder","Bandeau", "Boat Neck", "Scoop Neck"] }, "pattern": { "description": "Pattern of the garment", "data_type": "string", "allowed_values": [ "Floral","Stripe","Leopard Print","Spot","Plain","Geometric","Logo","Graphic print","Check","Tartan","Gingham", "Paisley", "other"] }, "fabric": { "description": "Material of the garment", "data_type": "string", "allowed_values": ["Cotton","Denim","Jersey","Linen","Satin","Silk","Sequin","Leather","Velvet","Corduroy","Ponte","Knit","Lace","Suede","Sheer","Chiffon", "Tulle", "Crepe", "Polyester","Viscose"] }, "features": { "description": "special features of the garment. None, should only be returned alone. Look closely as it is hard to directly see if a dress is lined, and pockets can be hidden. so use other cues such as the weight and see-trough level of the fabric etc", "data_type": "list[string]", "allowed_values": [ "Pockets", "Lined", "Cut Out", "Backless", "None"] }, "Closure": { "description": "Closure of the garment. How it is closed", "data_type": "list[string]", "allowed_values": [ "Button","Zip","Press Stud","Clasp"] }, "Body_Fit": { "description": "How the dress fits the body", "data_type": "string", "allowed_values": [ "Petite","Maternity","Regular","Tall","Plus Size"] }, "Occasion": { "description": "What occasions do the dress match", "data_type": "list[string]", "allowed_values": [ "Beach","Casual","Cocktail","Day","Bridal","Bridesmaid","Evening","Mother of the Bride","Party","Prom","Wedding Guest","Work","Sportswear"] }, "Season": { "description": "What season do the dress match", "data_type": "list[string]", "allowed_values": [ "Spring","Summer","Autumn","Winter"] }, """ ) #.replace(" ", "") FOLLOW_SCHEMA_SYSTEM = "You are an expert in structured data extraction. You will be given an dictionary of attributes of a product and should output the its properties into the given structure." FOLLOW_SCHEMA_HUMAN = """Given the data below, evaluate the most likely precise desctiption of each feature and return it as the structure looks. {json_info} """ class Prompts(BaseSettings): EXTRACT_INFO_SYSTEM_MESSAGE: str = EXTRACT_INFO_SYSTEM EXTRACT_INFO_HUMAN_MESSAGE: str = EXTRACT_INFO_HUMAN FOLLOW_SCHEMA_SYSTEM_MESSAGE: str = FOLLOW_SCHEMA_SYSTEM FOLLOW_SCHEMA_HUMAN_MESSAGE: str = FOLLOW_SCHEMA_HUMAN # Create a cached instance of settings @lru_cache def get_prompts() -> Prompts: """ Create and cache a Prompts instance. Returns the same instance for subsequent calls. """ prompts = Prompts() return prompts