fixed llm prompt

This commit is contained in:
2026-09-08 15:50:45 +03:00
parent b525e2ce1e
commit e2ee6c2a98
6 changed files with 704 additions and 102 deletions
+33 -3
View File
@@ -472,6 +472,7 @@ export default function ProjectPage() {
role: m.role,
content: m.content,
edits: m.proposed_edits || undefined,
tools: m.tool_calls || undefined,
}))
);
setChatContext(detail.context || null);
@@ -993,7 +994,10 @@ export default function ProjectPage() {
if (res.chat_id && res.chat_id !== activeChatId) {
setActiveChatId(res.chat_id);
}
setChat((c) => [...c, { role: "assistant", content: res.reply, edits: res.edits }]);
setChat((c) => [
...c,
{ role: "assistant", content: res.reply, edits: res.edits, tools: res.tools },
]);
setPendingEdits(res.edits?.length ? res.edits : null);
setChatContext(res.context || null);
await loadChats();
@@ -1054,6 +1058,15 @@ export default function ProjectPage() {
const data = await api.llmApply(projectId, tableType, pendingEdits);
historyPush(rows);
setRows(data.rows || []);
if (data.inscriptions) {
const next = {};
for (const [k, v] of Object.entries(data.inscriptions)) next[Number(k)] = v;
setInscriptions(next);
}
if (data.designators) {
setDesignators(data.designators);
setDesignatorsDirty(false);
}
setPendingEdits(null);
} catch (e) {
setError(e.message);
@@ -1797,8 +1810,9 @@ export default function ProjectPage() {
<div className="card stack">
<h3>LLM-помощник</h3>
<p className="muted">
Таблица в контексте: <strong>{tableLabel}</strong>. Команды вроде «добавь примечание к
R1». История чата учитывается. Правки — только после подтверждения.
Контекст: таблица <strong>{tableLabel}</strong>, основная надпись и дисигнаторы.
Можно просить правки строк, рамки («поле 111 = Иванов») и дисигнаторов («R →
Резистор/Резисторы»). Сортировку — явно. Правки применяются только после подтверждения.
</p>
<div className="row chat-toolbar">
<select
@@ -1861,6 +1875,22 @@ export default function ProjectPage() {
{chat.map((m, i) => (
<div key={i} className={`bubble ${m.role}`}>
{m.content}
{m.tools?.length ? (
<div className="chat-tools">
<div className="chat-tools-title">Инструменты</div>
{m.tools.map((t, ti) => (
<details key={ti} className="chat-tool" open={m.tools.length <= 3}>
<summary>
<code>{t.name}</code>
{t.round > 1 ? (
<span className="muted"> · шаг {t.round}</span>
) : null}
</summary>
<pre>{JSON.stringify(t.arguments ?? {}, null, 2)}</pre>
</details>
))}
</div>
) : null}
{m.edits?.length ? (
<div className="edits" style={{ marginTop: 6 }}>
Предложено правок: {m.edits.length}
+37
View File
@@ -383,6 +383,43 @@ table.data tr.page-break-marker td {
.context-meter-fill.mid { background: #c4a035; }
.context-meter-fill.high { background: #b14343; }
.edits { font-size: 0.8rem; background: #fff7ea; border: 1px dashed var(--accent-2); padding: 0.5rem; border-radius: 6px; }
.chat-tools {
margin-top: 0.5rem;
padding: 0.4rem 0.5rem;
background: #ebe6dc;
border-radius: 6px;
font-size: 0.78rem;
}
.chat-tools-title {
font-weight: 600;
margin-bottom: 0.3rem;
color: #5a5040;
}
.chat-tool {
margin: 0.25rem 0;
border-top: 1px solid #d9d0bf;
padding-top: 0.25rem;
}
.chat-tool summary {
cursor: pointer;
list-style: none;
}
.chat-tool summary code {
font-size: 0.78rem;
background: #f7f3ea;
padding: 0.05rem 0.3rem;
border-radius: 3px;
}
.chat-tool pre {
margin: 0.3rem 0 0;
white-space: pre-wrap;
word-break: break-word;
max-height: 160px;
overflow: auto;
background: #f7f3ea;
padding: 0.35rem;
border-radius: 4px;
}
.login-page {
min-height: 100vh;
display: grid;