Files
writing-agent/web/chat.html
T
chenmoranzhi 98e51f9c6c 直聊的种子历史改成逐条真多轮,不再靠块头文本猜轮次。
一条一个角色下拉加一整句正文,换行原样保留;旧盘里的纯文本在读盘时迁移,切得出轮次的转成条目,切不出的挪进史前设定免得悄悄丢掉。历史编辑器做成共用控件,预设工作台的用例与假历史也用同一套。
2026-10-26 01:09:34 +08:00

295 lines
11 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>直聊 · Writing Agent</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&family=Noto+Serif+SC:wght@500;600;700&display=swap"
rel="stylesheet"
/>
<script src="/theme-init.js"></script>
<link rel="stylesheet" href="/settings.css" />
<link rel="stylesheet" href="/history-editor.css" />
<link rel="stylesheet" href="/chat.css" />
</head>
<body class="settings-page chat-page">
<header class="st-top">
<a class="st-brand" href="/">Writing Agent</a>
<nav class="st-nav" aria-label="主导航">
<a href="/">对话</a>
<a href="/chat.html" aria-current="page">直聊</a>
<a href="/modules.html">技能</a>
<a href="/libraries.html">库</a>
<a href="/stats.html">Token</a>
<a href="/presets.html">预设</a>
<a href="/settings.html">设置</a>
</nav>
</header>
<div class="st-shell chat-shell">
<aside class="chat-rail" aria-label="直聊导航">
<nav class="path-bar chat-path" id="chat-path" aria-label="位置">
<ol class="path-bar-list" id="chat-path-list"></ol>
</nav>
<div class="chat-rail-actions">
<button type="button" class="st-btn" id="btn-new-shell">新建上下文</button>
<button type="button" class="st-btn" id="btn-new-conv" hidden>
新建会话
</button>
<button type="button" class="st-btn" id="btn-save-temp" hidden>
保存
</button>
</div>
<div class="chat-rail-list" id="chat-rail-list"></div>
<p class="chat-rail-note">
未选存档即为快速对话(浏览器缓存,最多 2 条),可保存为持久会话。
</p>
<button
type="button"
class="chat-rail-toggle chat-rail-toggle-left"
id="btn-hide-left"
title="收起对话列表"
aria-label="收起对话列表"
>‹</button>
</aside>
<main class="chat-main" id="chat-main">
<button
type="button"
class="chat-rail-reopen chat-rail-reopen-left"
id="btn-show-left"
title="展开对话列表"
aria-label="展开对话列表"
hidden
>›</button>
<button
type="button"
class="chat-rail-reopen chat-rail-reopen-right"
id="btn-show-right"
title="展开上下文"
aria-label="展开上下文"
hidden
>‹</button>
<section class="chat-room" id="chat-room">
<p class="chat-temp-mark" id="chat-temp-mark" hidden>临时会话</p>
<div class="chat-arena" id="chat-arena" aria-live="polite" aria-label="模型竞技场"></div>
<footer class="chat-composer">
<p class="chat-status" id="chat-status" hidden></p>
<div class="chat-composer-row">
<details class="chat-more" id="chat-more">
<summary class="chat-more-sum" title="更多操作" aria-label="更多操作">
<span class="hamburger-icon" aria-hidden="true"></span>
</summary>
<div class="chat-more-panel" id="chat-more-panel" role="menu"></div>
</details>
<div class="chat-input-shell">
<textarea
id="chat-input"
rows="1"
placeholder="输入消息,Enter 发送(所有模型同时回复),Shift+Enter 换行"
></textarea>
<div class="chat-shell-actions">
<button
type="button"
class="chat-btn-icon chat-btn-icon-primary"
id="btn-send"
title="发送(Enter)"
aria-label="发送"
>
<svg class="chat-send-icon" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">
<path fill="currentColor" d="M1.4 2.1 14.6 8 1.4 13.9l.2-4.4L10 8 1.6 6.5l-.2-4.4Z"/>
</svg>
</button>
</div>
</div>
</div>
</footer>
</section>
</main>
<aside class="chat-context" id="chat-context" aria-label="上下文配置">
<button
type="button"
class="chat-rail-toggle chat-rail-toggle-right"
id="btn-hide-right"
title="收起上下文"
aria-label="收起上下文"
>›</button>
<header class="chat-context-head">
<p class="chat-context-sub" id="context-sub">选择或新建后编辑</p>
</header>
<div class="chat-context-tabs" role="tablist" aria-label="上下文面板">
<button
type="button"
class="chat-context-tab is-active"
id="tab-shell"
data-context-tab="shell"
role="tab"
aria-selected="true"
aria-controls="shell-editor"
>
上下文
</button>
<button
type="button"
class="chat-context-tab"
id="tab-keep"
data-context-tab="keep"
role="tab"
aria-selected="false"
aria-controls="keep-stats"
>
保留统计
</button>
</div>
<div class="chat-shell-editor" id="shell-editor">
<label>
名称
<input type="text" id="shell-name" disabled />
</label>
<label>
系统提示
<textarea
id="shell-system"
rows="3"
placeholder="空则用默认直聊契约"
disabled
></textarea>
</label>
<label>
史前设定
<textarea id="shell-lore-before" rows="3" disabled></textarea>
</label>
<div class="chat-shell-field">
<span>种子历史(真多轮 user / assistant,拼在多轮之前)</span>
<div id="shell-seed-history" class="chat-shell-history"></div>
</div>
<label>
史后状态
<textarea id="shell-lore-after" rows="2" disabled></textarea>
</label>
<label>
尾注
<textarea id="shell-post-turn" rows="2" disabled></textarea>
</label>
<label>
角色名(对应预设里的 {{char}})
<input type="text" id="shell-char-name" placeholder="空则用「作品」" disabled />
</label>
<label>
角色描述(酒馆 Char Description 洞)
<textarea
id="shell-char-desc"
rows="3"
placeholder="空则这一条不发"
disabled
></textarea>
</label>
<label>
角色性格(酒馆 Char Personality 洞,会套预设的性格模板)
<textarea id="shell-char-pers" rows="2" disabled></textarea>
</label>
<label>
场景(酒馆 Scenario 洞,会套预设的场景模板)
<textarea id="shell-scenario" rows="2" disabled></textarea>
</label>
<label>
示例对话(酒馆 mes_example 格式,用 &lt;START&gt; 分块)
<textarea
id="shell-examples"
rows="3"
placeholder="例:&lt;START&gt;&#10;{{user}}: 你好&#10;{{char}}: 你也好"
disabled
></textarea>
</label>
<div class="chat-shell-editor-actions">
<button
type="button"
class="st-btn"
id="btn-clear-shell"
disabled
title="清空提示和设定,保留名称与已选模型"
>
清空
</button>
<button type="button" class="st-btn st-btn-primary" id="btn-save-shell" disabled>
应用
</button>
</div>
</div>
<div class="chat-keep-stats" id="keep-stats" role="tabpanel" aria-labelledby="tab-keep" hidden>
<p class="chat-keep-stats-hint" id="keep-stats-hint"></p>
<div class="chat-keep-stats-list" id="keep-stats-list"></div>
<div class="chat-keep-stats-foot">
<button type="button" class="st-btn" id="btn-clear-keep" hidden>清空统计</button>
</div>
</div>
</aside>
</div>
<dialog class="chat-dialog" id="dialog-promote">
<form method="dialog" id="form-promote">
<h3>保存临时会话</h3>
<label>
上下文名称
<input type="text" id="promote-shell-name" value="临时上下文" required />
</label>
<label>
会话名称
<input type="text" id="promote-conv-name" value="会话" required />
</label>
<div class="chat-dialog-actions">
<button type="submit" class="st-btn st-btn-primary" value="ok">保存</button>
<button type="submit" class="st-btn" value="cancel">取消</button>
</div>
</form>
</dialog>
<dialog class="chat-dialog" id="dialog-new-conv">
<form method="dialog" id="form-new-conv">
<h3>新建会话</h3>
<p class="chat-dialog-hint">勾选要同时回复的模型,可以多选。未勾选也能创建,之后再加。</p>
<label>
会话名称
<input type="text" id="new-conv-name" value="新会话" required />
</label>
<fieldset class="chat-model-pick">
<legend>模型</legend>
<div class="chat-compare-list" id="new-conv-models"></div>
<p class="chat-dialog-hint" id="new-conv-models-empty" hidden>
没有带 Key 的 API 配置。请先到设置里添加。
</p>
</fieldset>
<div class="chat-dialog-actions">
<button type="submit" class="st-btn st-btn-primary" value="ok">创建</button>
<button type="submit" class="st-btn" value="cancel" formnovalidate>取消</button>
</div>
</form>
</dialog>
<dialog class="chat-dialog" id="dialog-add-window">
<form method="dialog" id="form-add-window">
<h3>新增窗口</h3>
<p class="chat-dialog-hint">勾选要加入的模型,可以多选。已经在会话里的不能再选。</p>
<fieldset class="chat-model-pick">
<legend>模型</legend>
<div class="chat-compare-list" id="add-window-models"></div>
<p class="chat-dialog-hint" id="add-window-models-empty" hidden>
请至少再勾选一个模型。
</p>
</fieldset>
<div class="chat-dialog-actions">
<button type="submit" class="st-btn st-btn-primary" value="ok">添加</button>
<button type="submit" class="st-btn" value="cancel" formnovalidate>取消</button>
</div>
</form>
</dialog>
<script type="module" src="/chat.js"></script>
</body>
</html>