feat(frontend): add dynamic variable prompt editor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
AnalysisConfigEditor,
|
||||
} from "@/components/assistant-editor/analysis-config";
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
DynamicVariableEditorHint,
|
||||
DynamicVariablesSection,
|
||||
} from "@/components/assistant-editor/dynamic-variables";
|
||||
import { PromptTemplateEditor } from "@/components/assistant-editor/prompt-template-editor";
|
||||
import {
|
||||
AssistantIdentity,
|
||||
EditableTitle,
|
||||
@@ -200,6 +201,13 @@ export function PromptEditor({
|
||||
const [debugOpen, setDebugOpen] = useState(true);
|
||||
const [deleting, setDeleting] = useState(false);
|
||||
const [cleanupDialogOpen, setCleanupDialogOpen] = useState(false);
|
||||
const promptVariableSuggestions = useMemo(
|
||||
() => ({
|
||||
...form.dynamicVariableDefinitions,
|
||||
...dynamicVariableDefinitions,
|
||||
}),
|
||||
[form.dynamicVariableDefinitions, dynamicVariableDefinitions],
|
||||
);
|
||||
const selectedRealtimeModel = realtimeOptions.find(
|
||||
(option) => option.value === form.realtimeModel,
|
||||
);
|
||||
@@ -468,10 +476,12 @@ export function PromptEditor({
|
||||
title="提示词"
|
||||
description="描述助手的角色、能力和回答要求"
|
||||
>
|
||||
<TextAreaField
|
||||
<PromptTemplateEditor
|
||||
value={form.prompt}
|
||||
onChange={(value) => updateForm("prompt", value)}
|
||||
variables={promptVariableSuggestions}
|
||||
placeholder="请输入提示词,描述助手的角色、能力和回答要求"
|
||||
ariaLabel="提示词"
|
||||
rows={16}
|
||||
/>
|
||||
<DynamicVariableEditorHint
|
||||
@@ -485,10 +495,12 @@ export function PromptEditor({
|
||||
title="开场白"
|
||||
description="助手与用户首次对话时的开场语"
|
||||
>
|
||||
<TextAreaField
|
||||
<PromptTemplateEditor
|
||||
value={form.greeting}
|
||||
onChange={(value) => updateForm("greeting", value)}
|
||||
variables={promptVariableSuggestions}
|
||||
placeholder="请输入助手开场白"
|
||||
ariaLabel="开场白"
|
||||
/>
|
||||
<DynamicVariableEditorHint
|
||||
count={Object.keys(dynamicVariableDefinitions).length}
|
||||
|
||||
Reference in New Issue
Block a user