Update index.html
Browse files1571 unmodified lines157215731574157515761577157815791580158115821583158415851586158715881571 unmodified lines}async function callGenerateCompat(id, msgs, reqId_, roundOpts, onChunk, signal) {const args7 = [id, J(msgs), reqId_, cfg.maxTok, cfg.temp, cfg.topP, J(roundOpts)];try {return await call('generate', args7, onChunk, signal);} catch (e) {// توافق تراجعي في حال كان app.py بـ 6 معاملات فقطif (e.name !== 'AbortError' && /422|argument|generate/i.test(e.message)) {const args6 = [id, J(msgs), reqId_, cfg.maxTok, cfg.temp, cfg.topP];return await call('generate', args6, onChunk, signal);}throw e;}}async function run(s, text, docIds = []) {1571 unmodified lines157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091571 unmodified lines}async function callGenerateCompat(id, msgs, reqId_, roundOpts, onChunk, signal) {// 1. نرسل التجهيز (بحث/ويب) عبر prepare إذا كانت الميزة مفعّلةlet prepared = null;let finalMsgs = msgs;try {const q = msgs[msgs.length - 1].content;prepared = await call('prepare', [q,J(roundOpts.doc_ids || []),!!roundOpts.web,roundOpts.sid || '',roundOpts.user_sys || '',roundOpts.mem !== false,roundOpts.idx ?? -1], null, signal);if (prepared && prepared.ok) {if (prepared.prefix) {// دمج السياق (البحث/المصادر) في رسالة النظامfinalMsgs = msgs.map(m =>m.role === 'system' ? { role: 'system', content: m.content + '\n\n' + prepared.prefix } : m);}// نرسل المصادر والأدوات للواجهة ليتم عرضهاif (onChunk) onChunk({ tools: prepared.tools || [], sources: prepared.sources || [] });}} catch (e) {console.warn('prepare failed, falling back to raw generate', e);}// 2. نرسل التوليد النهائي عبر generateconst args = [id, J(finalMsgs), reqId_, cfg.maxTok, cfg.temp, cfg.topP, cfg.thinking];return await call('generate', args, onChunk, signal);}async function run(s, text, docIds = []) {
index.html+29-8