feat: add configurable chat display modes
This commit is contained in:
1 parent
3715af3138
commit
40542db400
18 files changed
+421
-121
No files matched your search
@@ -46,6 +46,8 @@ export default function PromptPrefixSettingsPage({
|
||||
const [enabled, setEnabled] = useState(false);
|
||||
const [switchLabel, setSwitchLabel] = useState("");
|
||||
const [promptPrefix, setPromptPrefix] = useState("");
|
||||
const [ordinaryQaMarkdownFormatEnabled, setOrdinaryQaMarkdownFormatEnabled] =
|
||||
useState(false);
|
||||
// Only seed the draft from server data once. Re-syncing every time react-query
|
||||
// refetches (window focus, route remount, etc.) would silently overwrite the
|
||||
// user's in-progress edits — and made the toggle look unresponsive: a click
|
||||
@@ -57,6 +59,9 @@ export default function PromptPrefixSettingsPage({
|
||||
setEnabled(data.enabled);
|
||||
setSwitchLabel(data.switch_label);
|
||||
setPromptPrefix(data.prompt_prefix);
|
||||
setOrdinaryQaMarkdownFormatEnabled(
|
||||
data.ordinary_qa_markdown_format_enabled === true,
|
||||
);
|
||||
initializedRef.current = true;
|
||||
}, [data]);
|
||||
|
||||
@@ -79,6 +84,8 @@ export default function PromptPrefixSettingsPage({
|
||||
enabled,
|
||||
switch_label: switchLabel,
|
||||
prompt_prefix: promptPrefix,
|
||||
ordinary_qa_markdown_format_enabled:
|
||||
ordinaryQaMarkdownFormatEnabled,
|
||||
});
|
||||
toast.success("已保存",darkToastOpts.success);
|
||||
} catch (e) {
|
||||
@@ -95,10 +102,9 @@ export default function PromptPrefixSettingsPage({
|
||||
}
|
||||
>
|
||||
<div>
|
||||
<h1 className={embedded ? "text-base font-semibold" : "text-xl font-semibold"}>问答前缀配置</h1>
|
||||
<h1 className={embedded ? "text-base font-semibold" : "text-xl font-semibold"}>问答提示词配置</h1>
|
||||
<p className="text-muted-foreground mt-1 text-sm">
|
||||
管理员可在此配置问答页输入框中的「前缀开关」。开启后,用户在新会话中第一次提问时,
|
||||
会将下方配置的前缀文本和原问题拼接后再发送给模型。
|
||||
管理员可在此配置问答前缀和普通问答的固定 Markdown 格式提示词。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -147,6 +153,21 @@ export default function PromptPrefixSettingsPage({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-start justify-between gap-4 rounded-lg border p-4">
|
||||
<div>
|
||||
<div className="text-sm font-medium">固定格式提示词</div>
|
||||
<p className="text-muted-foreground mt-1 max-w-md text-xs leading-relaxed">
|
||||
开启后,普通问答的长篇内容会按“# 主标题、## 一、标题、###
|
||||
(一) 标题、#### 1. 标题”的固定 Markdown 格式生成。默认关闭。
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
checked={ordinaryQaMarkdownFormatEnabled}
|
||||
onCheckedChange={setOrdinaryQaMarkdownFormatEnabled}
|
||||
aria-label="固定格式提示词"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end">
|
||||
<Button onClick={handleSave} disabled={update.isPending}>
|
||||
{update.isPending && (
|
||||
|
||||
Reference in new issue
Block a user