新增 随机池种类递减(把新增的类型从随机池中剔除) 随机池中剔除Socks , 通过llm template prompt 控制单个outfit的服装类别唯一性

This commit is contained in:
zhh
2025-11-27 10:47:17 +08:00
parent 347547da00
commit 9451e95667

View File

@@ -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()