fix(agent): v4.12.1 - champs cle API/URL API dans la config, AI Meeting Note en bloc de reunion interactif (transcription live + resume)
This commit is contained in:
@@ -163,6 +163,54 @@
|
||||
self.input = t;
|
||||
setTimeout(function(){ self.send(); }, 60);
|
||||
};
|
||||
// Headless generation (no panel): used by the AI Meeting Note block to
|
||||
// build its Summary. Returns a Promise of the final assistant text.
|
||||
window.fdAgent.generate = function(message, context){
|
||||
message = (message || '').trim();
|
||||
if(!message) return Promise.resolve('');
|
||||
var payload = {message: message};
|
||||
if(context && context.trim()) payload.context = String(context).slice(0, 20000);
|
||||
return fetch('/api/agent/conversations', {
|
||||
method:'POST', headers:{'Content-Type':'application/json'},
|
||||
body: JSON.stringify({title:'AI Meeting Note'})
|
||||
}).then(function(r){ return r.json(); }).then(function(conv){
|
||||
var cid = conv && conv.id;
|
||||
if(!cid) throw new Error('Impossible de créer une conversation agent');
|
||||
return fetch('/api/agent/conversations/' + cid + '/run', {
|
||||
method:'POST', headers:{'Content-Type':'application/json'},
|
||||
body: JSON.stringify(payload)
|
||||
}).then(function(resp){
|
||||
if(!resp.ok){
|
||||
return resp.json().then(function(j){ throw new Error(j.detail || ('HTTP ' + resp.status)); });
|
||||
}
|
||||
var reader = resp.body.getReader();
|
||||
var dec = new TextDecoder();
|
||||
var buf = '', finalText = '', lastError = '';
|
||||
function pump(){
|
||||
return reader.read().then(function(res){
|
||||
if(res.done){
|
||||
if(lastError) throw new Error(lastError);
|
||||
return finalText;
|
||||
}
|
||||
buf += dec.decode(res.value, {stream:true});
|
||||
var parts = buf.split('\n\n');
|
||||
buf = parts.pop();
|
||||
for(var i=0;i<parts.length;i++){
|
||||
var line = parts[i].replace(/^data:\s*/, '').trim();
|
||||
if(!line) continue;
|
||||
try{
|
||||
var ev = JSON.parse(line);
|
||||
if(ev.type === 'final') finalText = ev.content || '';
|
||||
else if(ev.type === 'error') lastError = ev.message || 'Erreur agent';
|
||||
}catch(e){}
|
||||
}
|
||||
return pump();
|
||||
});
|
||||
}
|
||||
return pump();
|
||||
});
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
// Only providers *configured and functional* (verified) are selectable,
|
||||
|
||||
Reference in New Issue
Block a user