diff --git a/app/server/ChatbotAgent/core/prompt.py b/app/server/ChatbotAgent/core/prompt.py index dce71f0..0d1dc2d 100644 --- a/app/server/ChatbotAgent/core/prompt.py +++ b/app/server/ChatbotAgent/core/prompt.py @@ -52,7 +52,8 @@ GENERAL_RULES = """## General Rule ### **Layering:** * Style at least 2-3 layers - +* Show white t-shirt, shirt hem under pull over cardigan and hoodies; Don't show hem in layerinmg except sweaters, cardigan and hoodies (if capable) +* Style hoodie under blazer/ bomber jacker, leathe jacket/ trechcoat to create a street style casual look (if capable) """ GENERAL_RULES_DICT = { @@ -78,6 +79,7 @@ GENERAL_RULES_DICT = { * Acceesory wear in a set of same metal colour (gold earrings with gold belt buckle) * Wear chokers or short necklaces with V-necks; wear long pendants with crew necks or turtlenecks. * Wear a belt in tuck-in outfits +* Style silk scarf for the neck; tie it on your bag handle, around your wrist, or use it as a belt for a pop of color. * No watches, No hats, No sunglasses""", } diff --git a/app/server/ChatbotAgent/core/stylist_agent_server.py b/app/server/ChatbotAgent/core/stylist_agent_server.py index fdccb18..199f8b0 100644 --- a/app/server/ChatbotAgent/core/stylist_agent_server.py +++ b/app/server/ChatbotAgent/core/stylist_agent_server.py @@ -182,33 +182,28 @@ class AsyncStylistAgent: gender=gender, n_results=1 ) - except ValueError as e: - print(f"检测到无效参数错误:{e}") - results = [] - if not results: - self.post_operation( - status="failed", - message=f"数据库中未找到符合 '{category}/{subcategory}' 和描述的单品。", - callback_url=self.callback_url, - img_path="", - ) - raise Exception(f"数据库中未找到符合 '{category}/{subcategory}' 和描述的单品。") + if not results: + print(f"No matching item found for description: {item_description}, category: {category}, subcategory: {subcategory}") + return None - # 3. 模拟 Agent 审核(实际应用中,你需要将图片发回给 Agent进行审核) - best_meta = results[0] # 第一个 batch 的第一个 metadata - item_id = best_meta['item_id'].replace("_img", "") - batch_source = best_meta['batch_source'] - return { - "item_id": item_id, # 从 metadata 字典中安全获取 - "category": best_meta['category'], - 'description': best_meta['description'], - "subcategory": best_meta['subcategory'], - "brand": best_meta['brand'], - "gpt_description": item_description, - "gpt_subcategory": subcategory, - "image_path": os.path.join(settings.DATA_ROOT, batch_source, 'image_data', f"{item_id}.jpg") - } + # 3. 模拟 Agent 审核(实际应用中,你需要将图片发回给 Agent进行审核) + best_meta = results[0] # 第一个 batch 的第一个 metadata + item_id = best_meta['item_id'].replace("_img", "") + batch_source = best_meta['batch_source'] + return { + "item_id": item_id, # 从 metadata 字典中安全获取 + "category": best_meta['category'], + 'description': best_meta['description'], + "subcategory": best_meta['subcategory'], + "brand": best_meta['brand'], + "gpt_description": item_description, + "gpt_subcategory": subcategory, + "image_path": os.path.join(settings.DATA_ROOT, batch_source, 'image_data', f"{item_id}.jpg") + } + except Exception as e: + print((f"Internal error in _get_next_item: {str(e)}")) + return None def _build_system_prompt(self, template: str, general_rule: str, request_summary: str = "", occasion: str = "", stylist_guide: str = "", current_category: str = "clothing", allowed_subcategories: list = [], max_len: int = 4) -> str: # 1. 材质偏好 (Occasion Material Map) @@ -426,12 +421,6 @@ class AsyncStylistAgent: allowed_subcategories = self._get_allowed_subcategories(occasions[0], category) # 4a. 检查类别是否有效 (重要步骤) if subcategory not in allowed_subcategories: - self.post_operation( - status="continue", - message=f"Invalid subcategory recommended by Agent: {subcategory} not in allowed subcategory list: {allowed_subcategories}. Ignore and continue", - callback_url=url, - img_path=merged_image_path, - ) failed_found_item_count += 1 continue diff --git a/docs/Styling AI rules.xlsx b/docs/Styling AI rules.xlsx index 64cedcc..d904c47 100644 Binary files a/docs/Styling AI rules.xlsx and b/docs/Styling AI rules.xlsx differ