From 5f50f3ec1a85840a9674bd7f6b9b5f57eba57dbe Mon Sep 17 00:00:00 2001 From: zhh Date: Thu, 20 Nov 2025 11:07:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E5=8F=96=E6=B6=88agent?= =?UTF-8?q?=E9=85=8D=E9=A5=B0=EF=BC=88=E4=BF=9D=E7=95=99=E9=9E=8B=E5=AD=90?= =?UTF-8?q?=EF=BC=89=E6=8E=A8=E8=8D=90=EF=BC=8C=E6=94=B9=E4=B8=BA=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E9=9A=8F=E6=9C=BA=E9=85=8D=E9=A5=B0=E6=90=AD=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChatbotAgent/core/stylist_agent_server.py | 19 +++++++++++-------- app/server/ChatbotAgent/core/system_prompt.py | 2 +- .../ChatbotAgent/core/vector_database.py | 1 + app/test/chromadb/random_accessories.py | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/server/ChatbotAgent/core/stylist_agent_server.py b/app/server/ChatbotAgent/core/stylist_agent_server.py index aacf70d..593137b 100644 --- a/app/server/ChatbotAgent/core/stylist_agent_server.py +++ b/app/server/ChatbotAgent/core/stylist_agent_server.py @@ -20,9 +20,9 @@ logger = logging.getLogger(__name__) class AsyncStylistAgent: CATEGORY_SET = { - 'Activewear', 'Dresses', 'Outerwear', 'Pants', 'Shirts & Tops', 'Skirts', 'Suits', 'Swimwear', 'Underwear' + 'Activewear', 'Dresses', 'Outerwear', 'Pants', 'Shirts & Tops', 'Skirts', 'Suits', 'Swimwear', 'Underwear', 'Shoes', # 取消推荐配饰 - # , 'Watches', 'Shopping Totes', 'Sunglasses', 'Handbags', 'Backpacks', 'Belts', 'Hats', 'Jewelry', 'Briefcases', 'Socks', 'Neckties', 'Shoes', 'Scarves & Shawls' + # , 'Watches', 'Shopping Totes', 'Sunglasses', 'Handbags', 'Backpacks', 'Belts', 'Hats', 'Jewelry', 'Briefcases', 'Socks', 'Neckties', 'Scarves & Shawls' } CATEGORY_SET_ALL = { 'Activewear', 'Dresses', 'Outerwear', 'Pants', 'Shirts & Tops', 'Skirts', 'Suits', 'Swimwear', 'Underwear', @@ -108,8 +108,8 @@ class AsyncStylistAgent: ## 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 coordination**. - 2. **Step Planning**: The styling sequence must follow a **top-down, inside-out** approach: major garments (tops/outerwear/bottoms/dresses). + 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: ```json @@ -129,7 +129,10 @@ class AsyncStylistAgent: * **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: - +start 10:59:36,396 +fitst image 10:59:51,551 +fitst 完成11:00:34,672 +all 完成11:02:57,355 ```json {{ "action": "stop", @@ -260,7 +263,7 @@ class AsyncStylistAgent: print(f"An error occurred during item retrieval: {e}") return None - def _get_random_accessories(self): + async def _get_random_accessories(self): results = self.local_db.random_get_accessories() # 3. 模拟 Agent 审核(实际应用中,你需要将图片发回给 Agent进行审核) @@ -343,7 +346,7 @@ class AsyncStylistAgent: logger.info(f"request data :{response_data} | JAVA callback info -> status:{response.status_code} | message:{response.text}") # 新增配饰 - new_item = self._get_random_accessories() + new_item = await self._get_random_accessories() self.outfit_items.append(new_item) user_input = self._build_user_input() gemini_response_text, response_data['path'] = await self._call_gemini(user_input, user_id) @@ -425,7 +428,7 @@ class AsyncStylistAgent: logger.info(f"request data :{response_data} | JAVA callback info -> status:{response.status_code} | message:{response.text}") # 新增配饰 - new_item = self._get_random_accessories() + new_item = await self._get_random_accessories() self.outfit_items.append(new_item) user_input = self._build_user_input() gemini_response_text, response_data['path'] = await self._call_gemini(user_input, user_id) diff --git a/app/server/ChatbotAgent/core/system_prompt.py b/app/server/ChatbotAgent/core/system_prompt.py index 7156586..39ab0bd 100644 --- a/app/server/ChatbotAgent/core/system_prompt.py +++ b/app/server/ChatbotAgent/core/system_prompt.py @@ -53,4 +53,4 @@ JSON FIELD REQUIREMENTS: - **style (string):** The overall aesthetic description (e.g., "Classic elegance", "Modern minimalist", "Bohemian vibe", "Edgy and contemporary"). - **color_preference (string or list):** User's preferred or excluded colors/tones (e.g., "Light colors only", "Avoid deep shades", "['Cream', 'Pale Blue']", "No preference"). - **clothing_type (string):** User's preference for specific garment types, material, or silhouette (e.g., "Lightweight maxi dress", "Skirt with silk blouse", "Tailored wide-leg pants", "Floral print"). -- **vibe_or_details (string):** Any other details, mood requirements, or specific constraints (e.g., "Needs to be comfortable and breathable", "Accent on accessories", "Must cover shoulders").""" +- **vibe_or_details (string):** Any other details, mood requirements, or specific constraints (e.g., "Needs to be comfortable and breathable", "Must cover shoulders").""" \ No newline at end of file diff --git a/app/server/ChatbotAgent/core/vector_database.py b/app/server/ChatbotAgent/core/vector_database.py index 1baee3f..6461b5e 100644 --- a/app/server/ChatbotAgent/core/vector_database.py +++ b/app/server/ChatbotAgent/core/vector_database.py @@ -68,6 +68,7 @@ class VectorDatabase(): FILTER_CRITERIA = { "$and": [ {"item_group_id": {"$ne": "Clothing"}}, + {"item_group_id": {"$ne": "Shoes"}}, # 新增:过滤 Shoes {"modality": "image"}, ] } diff --git a/app/test/chromadb/random_accessories.py b/app/test/chromadb/random_accessories.py index 4c494d8..063ddbf 100644 --- a/app/test/chromadb/random_accessories.py +++ b/app/test/chromadb/random_accessories.py @@ -10,6 +10,7 @@ COLLECTION_NAME = 'lc_clothing_embedding' FILTER_CRITERIA = { "$and": [ {"item_group_id": {"$ne": "Clothing"}}, + {"item_group_id": {"$ne": "Shoes"}}, # 新增:过滤 Shoes {"modality": "image"}, ] }