避免重复item加入回调参数中
This commit is contained in:
@@ -424,6 +424,9 @@ class AsyncStylistAgent:
|
||||
|
||||
# 3. 检查终止条件
|
||||
if gemini_data.get('action') == 'stop':
|
||||
if is_duplicate_by_key(response_data['items'], {"item_id": item_id, "category": item_category}):
|
||||
print("重复(按item_id判断),不插入")
|
||||
else:
|
||||
response_data['path'] = minio_path
|
||||
response_data['items'].append({"item_id": item_id, "category": item_category})
|
||||
response_data['status'] = "ok"
|
||||
@@ -540,3 +543,11 @@ class AsyncStylistAgent:
|
||||
|
||||
gcs_uri = f"gs://{bucket_name}/{blob_name}"
|
||||
return gcs_uri
|
||||
|
||||
|
||||
def is_duplicate_by_key(data, target_item):
|
||||
"""基于item_id快速判断重复"""
|
||||
# 提取所有item_id到集合
|
||||
existing_ids = {item['item_id'] for item in data}
|
||||
# 判断目标item_id是否在集合中
|
||||
return target_item['item_id'] in existing_ids
|
||||
|
||||
Reference in New Issue
Block a user