diff --git a/index.cfm b/index.cfm index 61970a0..0fbc4c7 100644 --- a/index.cfm +++ b/index.cfm @@ -64,7 +64,7 @@
Nubes - Сверка договоров v1.0.20 — Lucee + Сверка договоров v1.0.21 — Lucee
@@ -431,9 +431,30 @@ document.getElementById('btnFull').addEventListener('click', async function() { // ── Промпт ───────────────────────────────────────────────── var promptEditor = document.getElementById('promptEditor'); -promptEditor.value = localStorage.getItem('llm_prompt') || ''; +// Загружаем промпт с сервера при появлении contract_id +var origUploadNext = null; +(function() { + var checkPrompt = setInterval(function() { + if (contractId) { + clearInterval(checkPrompt); + fetch('/prompt.cfm?contract_id=' + contractId) + .then(function(r) { return r.json(); }) + .then(function(d) { if (d.OK) promptEditor.value = d.PROMPT || ''; }); + } + }, 500); +})(); +// Автосохранение на сервер при изменении +var promptTimer = null; promptEditor.addEventListener('input', function() { - localStorage.setItem('llm_prompt', this.value); + clearTimeout(promptTimer); + promptTimer = setTimeout(function() { + if (!contractId) return; + fetch('/prompt.cfm?contract_id=' + contractId, { + method: 'POST', + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({prompt: promptEditor.value}) + }); + }, 800); }); // ── Чат ─────────────────────────────────────────────────── diff --git a/prompt.cfm b/prompt.cfm new file mode 100644 index 0000000..b2a2a8d --- /dev/null +++ b/prompt.cfm @@ -0,0 +1,56 @@ + + + + +OK + + + + + CREATE TABLE IF NOT EXISTS prompts ( + contract_id UUID PRIMARY KEY REFERENCES contracts(id), + prompt_text TEXT NOT NULL + ) + + + + + + + + + + + + + + + + + + + DELETE FROM prompts WHERE contract_id = + + + + INSERT INTO prompts (contract_id, prompt_text) VALUES ( + , + + ) + + + + + + + SELECT prompt_text FROM prompts + WHERE contract_id = + + + + + + + + +#serializeJSON(result)#