v1.0.46: промпт на сервере — extractor читает из БД, UI сохраняет
This commit is contained in:
+16
-1
@@ -52,6 +52,18 @@
|
||||
<!--- Промпт --->
|
||||
<cfset prompt = 'Ты — анализатор договоров. Ниже текст спецификации услуг из договора облачного провайдера.
|
||||
|
||||
<!--- Промпт: из БД или стандартный --->
|
||||
<cfset promptText = "">
|
||||
<cfquery name="pq" datasource="baza">
|
||||
SELECT prompt_text FROM prompts WHERE contract_id = <cfqueryparam value="#sup.contract_id#" cfsqltype="cf_sql_varchar">
|
||||
</cfquery>
|
||||
<cfif pq.recordCount GT 0 AND len(pq.prompt_text)>
|
||||
<cfset promptText = pq.prompt_text>
|
||||
</cfif>
|
||||
|
||||
<cfif NOT len(promptText)>
|
||||
<cfset promptText = 'Ты — анализатор договоров. Ниже текст спецификации услуг из договора облачного провайдера.
|
||||
|
||||
Найди ВСЕ таблицы со списком услуг. Извлеки каждую строку в JSON-массив.
|
||||
|
||||
Для каждой строки верни:
|
||||
@@ -73,8 +85,11 @@
|
||||
|
||||
Текст документа:
|
||||
---
|
||||
#parsedText#
|
||||
{parsed_text}
|
||||
---'>
|
||||
</cfif>
|
||||
|
||||
<cfset prompt = replace(promptText, "{parsed_text}", parsedText, "ALL")>
|
||||
|
||||
<!--- Вызов LLM --->
|
||||
<cfset apiKey = "sk-ucI5YvOticoOQ9Kuj5K9mQ">
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<body>
|
||||
<div class="topbar">
|
||||
<img src="/nubes-logo.svg" alt="Nubes">
|
||||
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.45 — Lucee</span></span>
|
||||
<span class="title">Сверка договоров — LLM <span style="font-weight:400;color:var(--muted);font-size:12px;">v1.0.46 — Lucee</span></span>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
@@ -318,6 +318,16 @@ document.getElementById('llmBtn').addEventListener('click', async function() {
|
||||
btn.disabled = true;
|
||||
btn.innerHTML = '<span class="spinner"></span> LLM-анализ...';
|
||||
|
||||
// Сохранить промпт на сервер
|
||||
var p = promptEditor.value.trim() || DEFAULT_PROMPT;
|
||||
if (contractId) {
|
||||
fetch('/prompt.cfm?contract_id=' + contractId, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({prompt: p})
|
||||
});
|
||||
}
|
||||
|
||||
var diffCard = document.getElementById('diffCard');
|
||||
var diffBody = document.getElementById('diffBody');
|
||||
var diffStatus = document.getElementById('diffStatus');
|
||||
@@ -471,12 +481,26 @@ document.getElementById('promptSave').addEventListener('click', function() {
|
||||
localStorage.setItem('llm_prompt', p);
|
||||
document.getElementById('promptStatus').textContent = '✓ сохранено';
|
||||
setTimeout(function() { document.getElementById('promptStatus').textContent = ''; }, 1500);
|
||||
if (contractId) {
|
||||
fetch('/prompt.cfm?contract_id=' + contractId, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({prompt: p})
|
||||
});
|
||||
}
|
||||
});
|
||||
document.getElementById('promptReset').addEventListener('click', function() {
|
||||
promptEditor.value = DEFAULT_PROMPT;
|
||||
localStorage.removeItem('llm_prompt');
|
||||
document.getElementById('promptStatus').textContent = '✓ сброшен';
|
||||
setTimeout(function() { document.getElementById('promptStatus').textContent = ''; }, 1500);
|
||||
if (contractId) {
|
||||
fetch('/prompt.cfm?contract_id=' + contractId, {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({prompt: ''})
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user