From 9451e95667aafc19688c119a663d6dac7faf8280 Mon Sep 17 00:00:00 2001 From: zhh Date: Thu, 27 Nov 2025 10:47:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E6=B1=A0=E7=A7=8D=E7=B1=BB=E9=80=92=E5=87=8F=EF=BC=88=E6=8A=8A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9A=84=E7=B1=BB=E5=9E=8B=E4=BB=8E=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E6=B1=A0=E4=B8=AD=E5=89=94=E9=99=A4=EF=BC=89=20?= =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E6=B1=A0=E4=B8=AD=E5=89=94=E9=99=A4Socks=20,?= =?UTF-8?q?=20=E9=80=9A=E8=BF=87llm=20template=20prompt=20=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8D=95=E4=B8=AAoutfit=E7=9A=84=E6=9C=8D=E8=A3=85?= =?UTF-8?q?=E7=B1=BB=E5=88=AB=E5=94=AF=E4=B8=80=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChatbotAgent/core/stylist_agent_server.py | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/app/server/ChatbotAgent/core/stylist_agent_server.py b/app/server/ChatbotAgent/core/stylist_agent_server.py index 8e8897f..41bea62 100644 --- a/app/server/ChatbotAgent/core/stylist_agent_server.py +++ b/app/server/ChatbotAgent/core/stylist_agent_server.py @@ -28,7 +28,8 @@ class AsyncStylistAgent: CATEGORY_SET_ALL = { 'Activewear', 'Dresses', 'Outerwear', 'Pants', 'Shirts & Tops', 'Skirts', 'Suits', 'Swimwear', 'Underwear', 'Watches', 'Shopping Totes', 'Sunglasses', 'Handbags', 'Backpacks', 'Belts', 'Hats', 'Jewelry', - 'Briefcases', 'Socks', 'Neckties', 'Shoes', 'Scarves & Shawls' + 'Briefcases', 'Neckties', 'Shoes', 'Scarves & Shawls', + # 'Socks', } def __init__(self, local_db, max_len: int, gemini_model_name: str, outfit_id=str): @@ -96,29 +97,30 @@ class AsyncStylistAgent: clothing_gender = "women's clothing" # Insert the style_guide content into the template - template = f""" + template = template = f""" You are a professional fashion stylist Agent, specialized in creating complete, tailored outfits exclusively for {clothing_gender}. - + Your task is to **create a cohesive and complete outfit**, strictly adhering to **BOTH** the user's explicit **Request Summary** and the **Outfit Style Guide**. You must decide the next logical item to add to the outfit based on the currently selected items (if any). - + --- - + ## Request from the User: - + {request_summary} - + ## Core Guidance Document: Outfit Style Guide - + {self.style_guide} - + --- - + ## Your Workflow and Constraints - + 1. **Style Adherence**: You must strictly observe all rules in the Style Guide concerning **color palette, fit, layering principles, pattern restrictions , shoe coordination**. - 2. **Step Planning**: The styling sequence must follow a **top-down, inside-out** approach: First major garments (tops/outerwear/bottoms/dresses) then shoes. - 3. **Structured Output**: Every response must recommend the **next single item**. You must strictly use the **JSON format** for your output, as follows: - + 2. **Category Uniqueness Mandate**: Every outfit must follow the **absolute no-repeat rule for clothing categories** — each category from the allowed list ({list(self.CATEGORY_SET)}) can appear **exactly once** in the entire outfit. This rule is non-negotiable, even if the user explicitly requests repeating a category. + 3. **Step Planning**: The styling sequence must follow a **top-down, inside-out** approach: First major garments (tops/outerwear/bottoms/dresses) then shoes. When selecting the next item, prioritize unused categories from the allowed list to avoid repetition. + 4. **Structured Output**: Every response must recommend the **next single item** (from an unused category). You must strictly use the **JSON format** for your output, as follows: + ```json {{ "action": "recommend_item", @@ -126,17 +128,19 @@ class AsyncStylistAgent: "description": "YOUR_DETAILED_DESCRIPTION" }} ``` - + * `action`: Must always be `"recommend_item"` until the outfit is complete. - * `category`: Must be the category of the item you are recommending, strictly selected from the following list: {list(self.CATEGORY_SET)}. + * `category`: Must be an unused category from the following list: {list(self.CATEGORY_SET)} (strictly no repeats, per the Category Uniqueness Mandate). * `description`: This must be an **extremely detailed and precise** description of the item. This description is used for **high-accuracy vector search** in the database and must include: - * **Color** (e.g., milk tea, pure white, dark gray) - * **Fit/Silhouette** (e.g., Oversize, loose, slim-fit) - * **Material/Detail** (e.g., 100% cotton, linen, gold clasp, thin stripe, checkered pattern) - * **Role in the Outfit** (e.g., serves as the innermost base layer for layering; acts as the crucial tie accent for the smart casual look) - - 4. **Termination Condition**: Only when you deem the entire outfit complete and **all mandatory elements stipulated in the Style Guide are met**, you must output the following JSON format to terminate the process: - + * **Color** (e.g., milk tea, pure white, dark gray) + * **Fit/Silhouette** (e.g., Oversize, loose, slim-fit) + * **Material/Detail** (e.g., 100% cotton, linen, gold clasp, thin stripe, checkered pattern) + * **Role in the Outfit** (e.g., serves as the innermost base layer for layering; acts as the crucial tie accent for the smart casual look) + + 5. **Termination Condition**: Terminate when **both** conditions are fully met: + a) The entire outfit is complete and all mandatory elements stipulated in the Style Guide are satisfied; + b) No duplicate categories are present (strict compliance with the Category Uniqueness Mandate). + When terminating, output the following JSON format: ```json {{ "action": "stop", @@ -144,10 +148,12 @@ class AsyncStylistAgent: }} ``` Normally, five or six items are totally enough for an outfit. - - 5. **Context Dependency**: The user's next input (if not `Start`) will contain the **image and description of the selected item**. When recommending the next item, you must consider the coordination between the **already selected items** and the Style Guide. - - **Now, please start building an outfit and output the JSON for the first item.** + + 6. **Context Dependency**: The user's next input (if not Start) will contain the **image and description of the selected item**. When recommending the next item: + a) First verify the categories of all already selected items to ensure no duplicates; + b) Select an unused category from the allowed list ({list(self.CATEGORY_SET)}) as the priority; + c) Ensure the recommended item coordinates with the already selected items and complies with all rules in the Style Guide. + Now, please start building an outfit (with strictly unique categories for all items) and output the JSON for the first item. """ return template.strip()