diff --git a/ui/src/stores/index.ts b/ui/src/stores/index.ts
index 6177aea4b..732985518 100644
--- a/ui/src/stores/index.ts
+++ b/ui/src/stores/index.ts
@@ -10,6 +10,7 @@ import useApplicationStore from './modules/application'
import useDocumentStore from './modules/document'
import useProblemStore from './modules/problem'
import useLogStore from './modules/log'
+import usePromptStore from './modules/prompt'
const useStore = () => ({
common: useCommonStore(),
@@ -20,7 +21,8 @@ const useStore = () => ({
application: useApplicationStore(),
document: useDocumentStore(),
problem: useProblemStore(),
- log: useLogStore()
+ log: useLogStore(),
+ prompt: usePromptStore(),
})
export default useStore
diff --git a/ui/src/stores/modules/prompt.ts b/ui/src/stores/modules/prompt.ts
new file mode 100644
index 000000000..ec4be979d
--- /dev/null
+++ b/ui/src/stores/modules/prompt.ts
@@ -0,0 +1,40 @@
+import { defineStore } from 'pinia'
+
+export interface promptTypes {
+ user: string
+ formValue: { model_id: string, prompt: string }
+}
+
+const usePromptStore = defineStore({
+ id: 'prompt',
+ state: (): promptTypes[] => (JSON.parse(localStorage.getItem('PROMPT_CACHE') || '[]')),
+ actions: {
+ save(user: string, formValue: any) {
+ this.$state.forEach((item: any, index: number) => {
+ if (item.user === user) {
+ this.$state.splice(index, 1)
+ }
+ })
+ this.$state.push({ user, formValue })
+ localStorage.setItem('PROMPT_CACHE', JSON.stringify(this.$state))
+ },
+ get(user: string) {
+ for (let i = 0; i < this.$state.length; i++) {
+ if (this.$state[i].user === user) {
+ return this.$state[i].formValue
+ }
+ }
+ return {
+ model_id: '',
+ prompt: '内容:{data}\n' +
+ '\n' +
+ '请总结上面的内容,并根据内容总结生成 5 个问题。\n' +
+ '回答要求:\n' +
+ '- 请只输出问题;\n' +
+ '- 请将每个问题放置标签中。'
+ }
+ }
+ }
+})
+
+export default usePromptStore
\ No newline at end of file
diff --git a/ui/src/views/document/component/GenerateRelatedDialog.vue b/ui/src/views/document/component/GenerateRelatedDialog.vue
index 8c0764a9f..a5908a565 100644
--- a/ui/src/views/document/component/GenerateRelatedDialog.vue
+++ b/ui/src/views/document/component/GenerateRelatedDialog.vue
@@ -134,7 +134,7 @@ const {
params: { id } // id为datasetID
} = route as any
-const { model } = useStore()
+const { model, prompt, user } = useStore()
const emit = defineEmits(['refresh'])
@@ -147,15 +147,9 @@ const providerOptions = ref>([])
const documentIdList = ref([])
const FormRef = ref()
-const form = ref({
- model_id: '',
- prompt: '内容:{data}\n' +
- '\n' +
- '请总结上面的内容,并根据内容总结生成 5 个问题。\n' +
- '回答要求:\n' +
- '- 请只输出问题;\n' +
- '- 请将每个问题放置标签中。'
-})
+const userId = user.userInfo?.id as string
+const form = ref(prompt.get(userId))
+
const rules = reactive({
model_id: [{ required: true, message: '请选择AI 模型', trigger: 'blur' }],
@@ -176,6 +170,8 @@ const submitHandle = async (formEl: FormInstance) => {
}
await formEl.validate((valid, fields) => {
if (valid) {
+ // 保存提示词
+ prompt.save(user.userInfo?.id as string, form.value)
const data = { ...form.value, document_id_list: documentIdList.value }
documentApi.batchGenerateRelated(id, data).then(() => {
MsgSuccess('生成关联问题成功')
diff --git a/ui/src/views/paragraph/component/GenerateRelatedDialog.vue b/ui/src/views/paragraph/component/GenerateRelatedDialog.vue
index e5f185230..c76144d57 100644
--- a/ui/src/views/paragraph/component/GenerateRelatedDialog.vue
+++ b/ui/src/views/paragraph/component/GenerateRelatedDialog.vue
@@ -117,7 +117,7 @@