Spaces:
Running
Running
Force web AI dimension accessory queries to prefer Grob Eurogold and exclude Hafele
Browse files- search-plus-boot.js +3 -3
search-plus-boot.js
CHANGED
|
@@ -165,7 +165,7 @@ function searchProductsByContext(text,limit){
|
|
| 165 |
var specsN='';if(p.specs&&typeof p.specs==='object'){try{specsN=norm(Object.values(p.specs).join(' '));}catch(e){}}
|
| 166 |
var skuN=norm(p.sku||p.model||p.mod||'');
|
| 167 |
var price=p.priceNum||p.pn||0;if(!price)price=parseInt((p.price||p.p||'').toString().replace(/[^\d]/g,''))||0;
|
| 168 |
-
var img=p.image||p.img||p.i||'';var score=0;var dimMatch=_vaiAccessoryDimMatch(p,dimQuery);if(dimQuery
|
| 169 |
if(cat){var catKws=CATEGORY_MAP[cat]||[];var inCat=false;for(var ci=0;ci<catKws.length;ci++){if(catN.indexOf(catKws[ci])!==-1||nameN.indexOf(catKws[ci])!==-1){inCat=true;break;}}if(!inCat)continue;score+=30;}
|
| 170 |
if(brand){if(brandN.indexOf(brand)!==-1||nameN.indexOf(brand)!==-1)score+=25;else continue;}
|
| 171 |
if(price>0){if(price<priceRange.min||price>priceRange.max)continue;score+=10;}else if(priceRange.max<Infinity){continue;}
|
|
@@ -218,13 +218,13 @@ window.fetch=function(url,options){
|
|
| 218 |
if(product){_lastProduct=product;}else if(_lastProduct){product=_lastProduct;}
|
| 219 |
var contextProducts=[];
|
| 220 |
var cat=detectCategory(userText);var brand=detectBrand(userText);var priceRange=detectPriceRange(userText);var dimQuery=_vaiAccessoryDimQuery(userText);
|
| 221 |
-
var isContextQuery=cat||(brand&&!product)||(priceRange.max<Infinity||priceRange.min>0);
|
| 222 |
if(isContextQuery||!product){contextProducts=searchProductsByContext(userText,8);}
|
| 223 |
if(product&&/thiết kế|kiểu dáng|màu sắc|design|phong cách|chất liệu/i.test(userText)){
|
| 224 |
var imgV=product.image||product.img||product.i||'';
|
| 225 |
if(imgV){body.model=VISION_MODEL;var lu=body.messages[body.messages.length-1];if(lu&&lu.role==='user'&&typeof lu.content==='string')lu.content=[{type:'text',text:lu.content},{type:'image_url',image_url:{url:imgV}}];}
|
| 226 |
}
|
| 227 |
-
var strict='\n\n[QUY TẮC TUYỆT ĐỐI]:\n1. CHỈ trả lời dựa trên [DỮ LIỆU] bên dưới. KHÔNG bịa thông số/giá.\n2. Nếu không có data → "Em chưa có thông tin SP này, anh/chị liên hệ Zalo 0981873395".\n3. LUÔN đề cập TÊN SẢN PHẨM + GIÁ cụ thể.\n4. Gạch đầu dòng, ngắn gọn.\n5. Khi có nhiều SP: so sánh ưu/nhược.\n6. Cuối câu: gợi ý SP phù hợp nhất.\n7. Với phụ kiện tủ bếp Garis/Grob/Eurogold: học theo cấu trúc Garis. Các mã/khoang tủ/chiều rộng tủ/phủ bì/KT mặt cánh là kích thước tủ danh nghĩa; quy cách R/W hoặc kích thước sản phẩm là kích thước lọt lòng/thực của phụ kiện. Nếu khách hỏi phủ bì/tủ 300mm thì chọn mã có tủ danh nghĩa 300mm hoặc lọt lòng nhỏ hơn 300mm, thường lớn hơn 250mm. Ưu tiên Grob trước, sau đó Eurogold
|
| 228 |
if(product&&!isContextQuery){
|
| 229 |
var specs=product.specs||{};var ss='';if(typeof specs==='object')for(var sk2 in specs)ss+=sk2+':'+specs[sk2]+'; ';
|
| 230 |
var feats=(product.feats||[]).slice(0,10).join('; ');
|
|
|
|
| 165 |
var specsN='';if(p.specs&&typeof p.specs==='object'){try{specsN=norm(Object.values(p.specs).join(' '));}catch(e){}}
|
| 166 |
var skuN=norm(p.sku||p.model||p.mod||'');
|
| 167 |
var price=p.priceNum||p.pn||0;if(!price)price=parseInt((p.price||p.p||'').toString().replace(/[^\d]/g,''))||0;
|
| 168 |
+
var img=p.image||p.img||p.i||'';var score=0;var dimMatch=_vaiAccessoryDimMatch(p,dimQuery);if(dimQuery){if(['grob','eurogold','garis'].every(function(b){return brandN.indexOf(b)===-1;}))continue;if(!_vaiAccessoryTypeOk(p,text)||!dimMatch)continue;}if(dimMatch)score+=80;
|
| 169 |
if(cat){var catKws=CATEGORY_MAP[cat]||[];var inCat=false;for(var ci=0;ci<catKws.length;ci++){if(catN.indexOf(catKws[ci])!==-1||nameN.indexOf(catKws[ci])!==-1){inCat=true;break;}}if(!inCat)continue;score+=30;}
|
| 170 |
if(brand){if(brandN.indexOf(brand)!==-1||nameN.indexOf(brand)!==-1)score+=25;else continue;}
|
| 171 |
if(price>0){if(price<priceRange.min||price>priceRange.max)continue;score+=10;}else if(priceRange.max<Infinity){continue;}
|
|
|
|
| 218 |
if(product){_lastProduct=product;}else if(_lastProduct){product=_lastProduct;}
|
| 219 |
var contextProducts=[];
|
| 220 |
var cat=detectCategory(userText);var brand=detectBrand(userText);var priceRange=detectPriceRange(userText);var dimQuery=_vaiAccessoryDimQuery(userText);
|
| 221 |
+
var isContextQuery=dimQuery||cat||(brand&&!product)||(priceRange.max<Infinity||priceRange.min>0);
|
| 222 |
if(isContextQuery||!product){contextProducts=searchProductsByContext(userText,8);}
|
| 223 |
if(product&&/thiết kế|kiểu dáng|màu sắc|design|phong cách|chất liệu/i.test(userText)){
|
| 224 |
var imgV=product.image||product.img||product.i||'';
|
| 225 |
if(imgV){body.model=VISION_MODEL;var lu=body.messages[body.messages.length-1];if(lu&&lu.role==='user'&&typeof lu.content==='string')lu.content=[{type:'text',text:lu.content},{type:'image_url',image_url:{url:imgV}}];}
|
| 226 |
}
|
| 227 |
+
var strict='\n\n[QUY TẮC TUYỆT ĐỐI]:\n1. CHỈ trả lời dựa trên [DỮ LIỆU] bên dưới. KHÔNG bịa thông số/giá.\n2. Nếu không có data → "Em chưa có thông tin SP này, anh/chị liên hệ Zalo 0981873395".\n3. LUÔN đề cập TÊN SẢN PHẨM + GIÁ cụ thể.\n4. Gạch đầu dòng, ngắn gọn.\n5. Khi có nhiều SP: so sánh ưu/nhược.\n6. Cuối câu: gợi ý SP phù hợp nhất.\n7. Với phụ kiện tủ bếp Garis/Grob/Eurogold: học theo cấu trúc Garis. Các mã/khoang tủ/chiều rộng tủ/phủ bì/KT mặt cánh là kích thước tủ danh nghĩa; quy cách R/W hoặc kích thước sản phẩm là kích thước lọt lòng/thực của phụ kiện. Nếu khách hỏi phủ bì/tủ 300mm thì chọn mã có tủ danh nghĩa 300mm hoặc lọt lòng nhỏ hơn 300mm, thường lớn hơn 250mm. Ưu tiên Grob trước, sau đó Eurogold; Garis chỉ dùng làm mẫu tham chiếu cấu trúc. Khi khách hỏi kích thước phụ kiện tủ bếp thì KHÔNG lấy Hafele nếu có Grob/Eurogold/Garis phù hợp.';
|
| 228 |
if(product&&!isContextQuery){
|
| 229 |
var specs=product.specs||{};var ss='';if(typeof specs==='object')for(var sk2 in specs)ss+=sk2+':'+specs[sk2]+'; ';
|
| 230 |
var feats=(product.feats||[]).slice(0,10).join('; ');
|