From 46793ba271bdb88e8038a45281ab6ad2ea5eb660 Mon Sep 17 00:00:00 2001 From: pangkaicheng <924366729@qq.com> Date: Wed, 7 Jan 2026 17:26:44 +0800 Subject: [PATCH] UPDATE: add color constrain in vector database for wedding occasion avoiding black items. --- app/server/ChatbotAgent/agent_server.py | 4 ++-- .../ChatbotAgent/core/stylist_agent_server.py | 5 ++--- app/server/ChatbotAgent/core/vector_database.py | 14 +++++--------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/server/ChatbotAgent/agent_server.py b/app/server/ChatbotAgent/agent_server.py index 3af8ac3..6a3931c 100644 --- a/app/server/ChatbotAgent/agent_server.py +++ b/app/server/ChatbotAgent/agent_server.py @@ -357,10 +357,10 @@ if __name__ == "__main__": request_data = json.load(f) tasks_with_metadata = [] - for test_content in request_data[8:10]: + for test_content in request_data[9:10]: occasions = test_content['occasions'] request_summary = test_content['request_summary'] - for stylist_name in ["edi"]: + for stylist_name in ["crystal", "mini", "vera", "edi"]: stylist_agent_kwages['outfit_id'] = test_content['test_case_id'] + '_' + test_content['occasions'][0].replace('/', '_') + f"_{stylist_name}" stylist_agent_kwages['stylist_name'] = stylist_name stylist_agent_kwages['gender'] = "female" diff --git a/app/server/ChatbotAgent/core/stylist_agent_server.py b/app/server/ChatbotAgent/core/stylist_agent_server.py index 03b95c1..7b9484f 100644 --- a/app/server/ChatbotAgent/core/stylist_agent_server.py +++ b/app/server/ChatbotAgent/core/stylist_agent_server.py @@ -313,7 +313,7 @@ class AsyncStylistAgent: if status in ['failed']: # 失败直接打印参数 不发送结果 response_data['message'] = message - logger.info(f"request data :{json.dumps(response_data, ensure_ascii=False, indent=2)}") + logger.error(f"request data :{json.dumps(response_data, ensure_ascii=False, indent=2)}") else: response = post_request(url=callback_url, data=json.dumps(response_data)) logger.info(f"request data :{json.dumps(response_data, ensure_ascii=False, indent=2)} | JAVA callback info -> status:{response.status_code} | message:{response.text}") @@ -646,11 +646,10 @@ class AsyncStylistAgent: else: self.post_operation( status="failed", - message=f"Failed to assemble a complete outfit after {max_retries} attempts for {occasions[0]}.", + message=f"Failed to assemble a complete outfit after {max_retries} attempts for {occasions[0]}. Current items: {self.outfit_items}. Subcategories required by this occasion is: {allowed_subcategories}", callback_url=url, img_path="" ) - logger.error(f"Failed to assemble a complete outfit after {max_retries} attempts for {occasions[0]}. Current items: {self.outfit_items}. Subcategories required by this occasion is: {allowed_subcategories}") raise Exception(f"Failed to assemble a complete outfit after {max_retries} attempts for {occasions[0]}. Current items: {self.outfit_items}. Subcategories required by this occasion is: {allowed_subcategories}") # 推荐即将完成 回调通知前端 diff --git a/app/server/ChatbotAgent/core/vector_database.py b/app/server/ChatbotAgent/core/vector_database.py index 06f83a4..0b9bcf6 100644 --- a/app/server/ChatbotAgent/core/vector_database.py +++ b/app/server/ChatbotAgent/core/vector_database.py @@ -67,16 +67,12 @@ class VectorDatabase(): if brand_strication: and_conditions.append({"brand": {"$in": BRAND_WHITELIST}}) - if batch_sources and len(batch_sources) > 0: - if len(batch_sources) == 1: - and_conditions.append({"batch_source": batch_sources[0]}) - else: - source_conditions = [] - for source in batch_sources: - source_conditions.append({"batch_source": source}) + # 加一条occasion限制,婚礼不能穿黑色 + if any(o in ["Bridal / Wedding", "Beach / Swim"] for o in occasions): + and_conditions.append({"color": {"$nin": ["BLACK", "DARK GREY", "DARK BLUE", "NAVY"]}}) - # 将 Batch Source 的 OR 子句添加到主 AND 条件中 - and_conditions.append({"$or": source_conditions}) + if batch_sources and len(batch_sources) > 0: + and_conditions.append({"batch_source": {"$in": batch_sources}}) results = self.collection.query( query_embeddings=[embedding],