Spaces:
Running
Running
v16: AI hook APPENDS product data to existing system prompt (no longer overrides natural sales consultant prompt)
Browse files- search-plus-boot.js +10 -3
search-plus-boot.js
CHANGED
|
@@ -164,10 +164,17 @@ window.fetch=function(url,options){
|
|
| 164 |
contextProducts.forEach(function(r,idx2){var cp=r.p;strict+='\n'+(idx2+1)+'. '+(cp.name||cp.n)+' | Giá:'+(cp.price||cp.p||'LH')+' | Mã:'+(cp.sku||cp.mod||'');if(cp.brand)strict+=' | '+cp.brand;var f=(cp.feats||[]).slice(0,3).join(', ');if(f)strict+=' | '+f;});
|
| 165 |
strict+='\n\n→ Giới thiệu TẤT CẢ SP trên, nêu tên + giá + ưu điểm chính. Gợi ý SP phù hợp nhất.';
|
| 166 |
}
|
|
|
|
| 167 |
var sys=body.messages.find(function(m){return m.role==='system';});
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
options.body=JSON.stringify(body);
|
| 172 |
}
|
| 173 |
}catch(e){console.warn('[Boot v16] hookAI error:',e);}
|
|
|
|
| 164 |
contextProducts.forEach(function(r,idx2){var cp=r.p;strict+='\n'+(idx2+1)+'. '+(cp.name||cp.n)+' | Giá:'+(cp.price||cp.p||'LH')+' | Mã:'+(cp.sku||cp.mod||'');if(cp.brand)strict+=' | '+cp.brand;var f=(cp.feats||[]).slice(0,3).join(', ');if(f)strict+=' | '+f;});
|
| 165 |
strict+='\n\n→ Giới thiệu TẤT CẢ SP trên, nêu tên + giá + ưu điểm chính. Gợi ý SP phù hợp nhất.';
|
| 166 |
}
|
| 167 |
+
// APPEND product data to existing system prompt (don't replace)
|
| 168 |
var sys=body.messages.find(function(m){return m.role==='system';});
|
| 169 |
+
if(sys&&typeof sys.content==='string'){
|
| 170 |
+
// Inline code already has excellent sales consultant prompt
|
| 171 |
+
// We just APPEND real product data so AI can reference it
|
| 172 |
+
sys.content+=strict;
|
| 173 |
+
}else{
|
| 174 |
+
// Fallback: no system prompt exists, create one
|
| 175 |
+
var sysPrompt='Bạn là V.AI STUDIO — chuyên gia tư vấn thiết bị nhà bếp. Xưng em, gọi anh/chị. Tư vấn tự nhiên như người thật, phân tích nhu cầu, giải thích tại sao SP phù hợp. Dùng data SP bên dưới.';
|
| 176 |
+
body.messages.unshift({role:'system',content:sysPrompt+strict});
|
| 177 |
+
}
|
| 178 |
options.body=JSON.stringify(body);
|
| 179 |
}
|
| 180 |
}catch(e){console.warn('[Boot v16] hookAI error:',e);}
|