The scheduler AI dock read the poll envelope as the job, so every answer hung on thinking
This commit is contained in:
@@ -80,11 +80,15 @@
|
||||
// CSRF prepend never reaches here and a request that dies inside the include never reaches the
|
||||
// action log below, and those two look identical from outside — which is what made a POST that
|
||||
// the browser demonstrably sent leave no trace anywhere on the server.
|
||||
@file_put_contents('/var/log/varaverk/ai.log',
|
||||
date('Y-m-d H:i:s') . ' ENTER ' . ($_SERVER['REQUEST_METHOD'] ?? '?')
|
||||
. ' ' . ($_SERVER['REQUEST_URI'] ?? '?')
|
||||
. ' ct=' . substr($_SERVER['CONTENT_TYPE'] ?? '-', 0, 40)
|
||||
. ' len=' . ($_SERVER['CONTENT_LENGTH'] ?? '-') . "\n", FILE_APPEND | LOCK_EX);
|
||||
// Polls are excluded here for the same reason they are excluded from the action log below: one
|
||||
// line per second per open tab buries every line worth reading.
|
||||
if (strpos($_SERVER['REQUEST_URI'] ?? '', 'action=poll') === false) {
|
||||
@file_put_contents('/var/log/varaverk/ai.log',
|
||||
date('Y-m-d H:i:s') . ' ENTER ' . ($_SERVER['REQUEST_METHOD'] ?? '?')
|
||||
. ' ' . ($_SERVER['REQUEST_URI'] ?? '?')
|
||||
. ' ct=' . substr($_SERVER['CONTENT_TYPE'] ?? '-', 0, 40)
|
||||
. ' len=' . ($_SERVER['CONTENT_LENGTH'] ?? '-') . "\n", FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Cache-Control: no-store, no-cache');
|
||||
|
||||
@@ -2429,11 +2429,15 @@ function vvAiDockSend() {
|
||||
}).catch(e => vvAiDockDone('Request failed: ' + e, true));
|
||||
}
|
||||
|
||||
function vvAiDockPoll(token) {
|
||||
function vvAiDockPoll(token, started) {
|
||||
started = started || Date.now();
|
||||
clearTimeout(vvAiPoll);
|
||||
if (Date.now() - started > 300000) return vvAiDockDone('Timed out waiting for a response.', true);
|
||||
vvAiPoll = setTimeout(() => {
|
||||
fetch('/plugins/varaverk/api/ai.php?action=poll&token=' + encodeURIComponent(token))
|
||||
.then(r => r.json()).then(j => {
|
||||
.then(r => r.json()).then(d => {
|
||||
if (!d.ok) return vvAiDockDone(d.error || 'Poll failed', true);
|
||||
const j = d.job || {};
|
||||
if (j.status === 'done') {
|
||||
vvAiHist.push({ role: 'assistant', content: j.answer || '' });
|
||||
vvAiDockDone(j.answer || '(empty answer)', false, j.sources || []);
|
||||
@@ -2443,7 +2447,7 @@ function vvAiDockPoll(token) {
|
||||
return;
|
||||
}
|
||||
if (j.status === 'error') return vvAiDockDone(j.error || 'Unknown error', true);
|
||||
vvAiDockPoll(token);
|
||||
vvAiDockPoll(token, started);
|
||||
}).catch(e => vvAiDockDone('Poll failed: ' + e, true));
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user