Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-fe
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-fe
Commits
491141b5
Commit
491141b5
authored
Nov 03, 2024
by
shirlyn.guo
👌🏻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 记忆片段
parent
4b354333
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
455 additions
and
64 deletions
+455
-64
memory.ts
src/apis/memory.ts
+19
-0
memory-fragment.png
src/assets/images/memory-fragment.png
+0
-0
zh-cn.yaml
src/locales/langs/zh-cn.yaml
+12
-0
zh-hk.yaml
src/locales/langs/zh-hk.yaml
+15
-3
personal-app-config.ts
src/store/modules/personal-app-config.ts
+1
-0
personal-app-config.ts
src/store/types/personal-app-config.ts
+2
-1
app-preview.vue
...nal-space/personal-app-setting/components/app-preview.vue
+19
-4
app-setting.vue
...nal-space/personal-app-setting/components/app-setting.vue
+93
-23
memory-preview-modal.vue
.../personal-app-setting/components/memory-preview-modal.vue
+217
-23
memory-variable-modal.vue
...personal-app-setting/components/memory-variable-modal.vue
+65
-10
locales.d.ts
types/locales.d.ts
+12
-0
No files found.
src/apis/memory.ts
0 → 100644
View file @
491141b5
import
{
request
}
from
'@/utils/request'
export
function
fetchGetLongMemoryList
<
T
>
(
agentId
:
string
)
{
return
request
.
post
<
T
>
(
`/agentApplicationInfoRest/getLongMemoryList.json?agentId=
${
agentId
}
`
)
}
export
function
fetchDeleteLongMemoryByKey
<
T
>
(
agentId
:
string
,
timestamp
:
string
)
{
return
request
.
post
<
T
>
(
`/agentApplicationInfoRest/deleteLongMemoryByKey.json?agentId=
${
agentId
}
×tamp=
${
timestamp
}
`
,
)
}
export
function
fetchDeleteAllLongMemory
<
T
>
(
agentId
:
string
)
{
return
request
.
post
<
T
>
(
`/agentApplicationInfoRest/deleteLongMemory.json?agentId=
${
agentId
}
`
)
}
export
function
fetchGetMemoryVariableList
<
T
>
(
agentId
:
string
)
{
return
request
.
post
<
T
>
(
`/agentApplicationInfoRest/getVariableList.json?agentId=
${
agentId
}
`
)
}
src/assets/images/memory-fragment.png
0 → 100644
View file @
491141b5
39.3 KB
src/locales/langs/zh-cn.yaml
View file @
491141b5
...
@@ -69,6 +69,10 @@ common_module:
...
@@ -69,6 +69,10 @@ common_module:
collect_unsubscribed
:
'
已取消收藏'
collect_unsubscribed
:
'
已取消收藏'
cancel
:
'
取消'
cancel
:
'
取消'
preservation
:
'
保存'
preservation
:
'
保存'
open
:
'
开'
close
:
'
关'
delete_tip_title
:
'
删除提示'
wipe_data
:
'
清空数据'
dialogue_module
:
dialogue_module
:
continue_question_message
:
'
你可以继续提问'
continue_question_message
:
'
你可以继续提问'
...
@@ -244,6 +248,11 @@ personal_space_module:
...
@@ -244,6 +248,11 @@ personal_space_module:
memory_variable_action_copy
:
'
复制名称'
memory_variable_action_copy
:
'
复制名称'
variable_name
:
'
变量名称'
variable_name
:
'
变量名称'
variable_value
:
'
变量值'
variable_value
:
'
变量值'
memory_fragment
:
'
记忆片段'
memory_fragment_message
:
'
开启记忆片段功能,应用将根据对话内容存储用户提及的信息片段,并依据记忆片段答复。下面以「面试助手」为例:'
memory_fragment_content
:
'
记录聊天对话中所有关于用户信息、用户偏好、用户计划的记忆片段。'
memory_variable_delete_tip_content
:
'
删除后不可撤销。如应用已发布,更新发布后该应用的用户无法使用该记忆变量,是否继续?'
memory_fragment_delete_all_tip_content
:
'
数据清空后不可撤销,确定要全部清空吗?'
memory_variable_modal
:
memory_variable_modal
:
edit_memory_variable
:
'
编辑记忆变量'
edit_memory_variable
:
'
编辑记忆变量'
...
@@ -259,6 +268,9 @@ personal_space_module:
...
@@ -259,6 +268,9 @@ personal_space_module:
default_value_placeholder
:
'
请输入'
default_value_placeholder
:
'
请输入'
name_placeholder
:
'
请输入名称'
name_placeholder
:
'
请输入名称'
add_variable
:
'
新增变量'
add_variable
:
'
新增变量'
memory_variable_add_now
:
'
立即添加'
none_memory_variable
:
'
暂无记忆变量'
add_variable_message
:
'
添加记忆变量,更好地记录用户特征、用户信息'
memory_variable_rules
:
memory_variable_rules
:
name_not_null
:
'
请输入名称'
name_not_null
:
'
请输入名称'
...
...
src/locales/langs/zh-hk.yaml
View file @
491141b5
...
@@ -69,6 +69,10 @@ common_module:
...
@@ -69,6 +69,10 @@ common_module:
collect_unsubscribed
:
'
已取消收藏'
collect_unsubscribed
:
'
已取消收藏'
cancel
:
'
取消'
cancel
:
'
取消'
preservation
:
'
保存'
preservation
:
'
保存'
open
:
'
開'
close
:
'
關'
delete_tip_title
:
'
删除提示'
wipe_data
:
'
清空數據'
dialogue_module
:
dialogue_module
:
continue_question_message
:
'
你可以繼續提問'
continue_question_message
:
'
你可以繼續提問'
...
@@ -237,13 +241,18 @@ personal_space_module:
...
@@ -237,13 +241,18 @@ personal_space_module:
add_memory_variable
:
'
添加記憶變數'
add_memory_variable
:
'
添加記憶變數'
memory_variable
:
'
記憶變量'
memory_variable
:
'
記憶變量'
memory_message
:
memory_message
:
'
开发者可根据应用设定记忆变量,应用用户在对话过程中可以录入变量内容,每个变量支持存储一维、单个数据
。
'
開發者可根據應用設定記憶變數,應用用戶在對話過程中可以錄入變數內容,每個變數支持存儲一維、單個數據
。
在
对话过程中,应用将依据存储的变量值进行答复。下面以「旅游助手」为
例:'
在
對話過程中,應用將依據存儲的變數值進行答覆。
下面以「旅遊助手」為
例:'
memory_variable_message
:
'
记录聊天对话中的一维、单个的应用信息或用户信息,能让智能体回答更加个
性化。'
memory_variable_message
:
'
記錄聊天對話中的一維、單個的應用資訊或用戶資訊,能讓智慧體回答更加個
性化。'
memory_variable_action_edit
:
'
編輯'
memory_variable_action_edit
:
'
編輯'
memory_variable_action_copy
:
'
複製名稱'
memory_variable_action_copy
:
'
複製名稱'
variable_name
:
'
变量名稱'
variable_name
:
'
变量名稱'
variable_value
:
'
变量值'
variable_value
:
'
变量值'
memory_fragment
:
'
記憶片段'
memory_fragment_message
:
'
開啟記憶片段功能,應用將根據對話內容存儲用戶提及的資訊片段,並依據記憶片段答覆。
下面以「面試助手」為例'
memory_fragment_content
:
'
記錄聊天對話中所有關於用戶資訊、用戶偏好、用戶計畫的記憶片段。'
memory_variable_delete_tip_content
:
'
删除後不可撤銷。
如應用已發佈,更新發佈後該應用的用戶無法使用該記憶變數,是否繼續?'
memory_fragment_delete_all_tip_content
:
'
數據清空後不可撤銷,確定要全部清空嗎?'
memory_variable_modal
:
memory_variable_modal
:
edit_memory_variable
:
'
編輯記憶變數'
edit_memory_variable
:
'
編輯記憶變數'
...
@@ -259,6 +268,9 @@ personal_space_module:
...
@@ -259,6 +268,9 @@ personal_space_module:
default_value_placeholder
:
'
請輸入'
default_value_placeholder
:
'
請輸入'
name_placeholder
:
'
請輸入名稱'
name_placeholder
:
'
請輸入名稱'
add_variable
:
'
新增變數'
add_variable
:
'
新增變數'
memory_variable_add_now
:
'
立即添加'
none_memory_variable
:
'
暫無記憶變數'
add_variable_message
:
'
添加記憶變數,更好地記錄用戶特徵、用戶資訊'
memory_variable_rules
:
memory_variable_rules
:
name_not_null
:
'
請求輸入名稱'
name_not_null
:
'
請求輸入名稱'
...
...
src/store/modules/personal-app-config.ts
View file @
491141b5
...
@@ -18,6 +18,7 @@ export function defaultPersonalAppConfigState(): PersonalAppConfigState {
...
@@ -18,6 +18,7 @@ export function defaultPersonalAppConfigState(): PersonalAppConfigState {
continuousQuestionSystem
:
''
,
continuousQuestionSystem
:
''
,
continuousQuestionTurn
:
3
,
continuousQuestionTurn
:
3
,
variableStructure
:
[],
variableStructure
:
[],
isLongMemory
:
'N'
,
},
},
knowledgeConfig
:
{
knowledgeConfig
:
{
knowledgeIds
:
[],
knowledgeIds
:
[],
...
...
src/store/types/personal-app-config.ts
View file @
491141b5
...
@@ -18,7 +18,8 @@ export interface PersonalAppConfigState {
...
@@ -18,7 +18,8 @@ export interface PersonalAppConfigState {
continuousQuestionStatus
:
'default'
|
'close'
//追问状态
continuousQuestionStatus
:
'default'
|
'close'
//追问状态
continuousQuestionSystem
:
string
// 追问提示词 customizable时必填
continuousQuestionSystem
:
string
// 追问提示词 customizable时必填
continuousQuestionTurn
:
number
// 追问轮次 1-5 customizable时必填
continuousQuestionTurn
:
number
// 追问轮次 1-5 customizable时必填
variableStructure
:
VariableStructureItem
[]
variableStructure
:
VariableStructureItem
[]
|
null
isLongMemory
:
string
}
}
knowledgeConfig
:
{
knowledgeConfig
:
{
knowledgeIds
:
string
[]
//知识库ID
knowledgeIds
:
string
[]
//知识库ID
...
...
src/views/personal-space/personal-app-setting/components/app-preview.vue
View file @
491141b5
...
@@ -24,6 +24,7 @@ const continuousQuestionStatus = ref<'default' | 'close'>(personalAppConfigStore
...
@@ -24,6 +24,7 @@ const continuousQuestionStatus = ref<'default' | 'close'>(personalAppConfigStore
const
continuousQuestionList
=
ref
<
string
[]
>
([])
const
continuousQuestionList
=
ref
<
string
[]
>
([])
const
isShowMemoryPreviewModal
=
ref
(
false
)
const
isShowMemoryPreviewModal
=
ref
(
false
)
const
selectedMemoryTabName
=
ref
(
'memoryVariable'
)
function
handleAddMessageItem
(
messageItem
:
ConversationMessageItem
)
{
function
handleAddMessageItem
(
messageItem
:
ConversationMessageItem
)
{
messageList
.
value
.
push
(
messageItem
)
messageList
.
value
.
push
(
messageItem
)
...
@@ -82,7 +83,8 @@ function handleUpdateContinueQuestionStatus(status: 'default' | 'close') {
...
@@ -82,7 +83,8 @@ function handleUpdateContinueQuestionStatus(status: 'default' | 'close') {
// })
// })
// }
// }
function
handleMemoryVariable
()
{
function
handleOpenMemoryPreviewModal
(
MemoryTabName
:
string
)
{
selectedMemoryTabName
.
value
=
MemoryTabName
isShowMemoryPreviewModal
.
value
=
true
isShowMemoryPreviewModal
.
value
=
true
}
}
</
script
>
</
script
>
...
@@ -95,7 +97,13 @@ function handleMemoryVariable() {
...
@@ -95,7 +97,13 @@ function handleMemoryVariable() {
{{
t
(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.preview'
)
}}
{{
t
(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.preview'
)
}}
</p>
</p>
<div
v-show=
"personalAppConfigStore.commConfig.variableStructure !== null"
class=
"cursor-pointer"
>
<div
v-show=
"
personalAppConfigStore.commConfig.variableStructure !== null ||
personalAppConfigStore.commConfig.isLongMemory === 'Y'
"
class=
"cursor-pointer"
>
<n-popover
placement=
"bottom"
trigger=
"hover"
class=
"p-[4px]!"
:show-arrow=
"false"
>
<n-popover
placement=
"bottom"
trigger=
"hover"
class=
"p-[4px]!"
:show-arrow=
"false"
>
<template
#
trigger
>
<template
#
trigger
>
<div
class=
"flex items-center justify-center px-5 text-[14px]"
>
<div
class=
"flex items-center justify-center px-5 text-[14px]"
>
...
@@ -110,10 +118,17 @@ function handleMemoryVariable() {
...
@@ -110,10 +118,17 @@ function handleMemoryVariable() {
<div
<div
v-show=
"personalAppConfigStore.commConfig.variableStructure !== null"
v-show=
"personalAppConfigStore.commConfig.variableStructure !== null"
class=
"cursor-pointer px-[8px] py-[5px] hover:bg-[#f2f5f9]"
class=
"cursor-pointer px-[8px] py-[5px] hover:bg-[#f2f5f9]"
@
click=
"handle
MemoryVariable
"
@
click=
"handle
OpenMemoryPreviewModal('memoryVariable')
"
>
>
{{ t('personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable') }}
{{ t('personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable') }}
</div>
</div>
<div
v-show=
"personalAppConfigStore.commConfig.isLongMemory === 'Y'"
class=
"cursor-pointer px-[8px] py-[5px] hover:bg-[#f2f5f9]"
@
click=
"handleOpenMemoryPreviewModal('memoryFragment')"
>
{{ t('personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_fragment') }}
</div>
</div>
</div>
</n-popover>
</n-popover>
</div>
</div>
...
@@ -157,7 +172,7 @@ function handleMemoryVariable() {
...
@@ -157,7 +172,7 @@ function handleMemoryVariable() {
@
update-continuous-question-status=
"handleUpdateContinueQuestionStatus"
@
update-continuous-question-status=
"handleUpdateContinueQuestionStatus"
/>
/>
<MemoryPreviewModal
v-model=
"isShowMemoryPreviewModal"
/>
<MemoryPreviewModal
v-model=
"isShowMemoryPreviewModal"
:data=
"selectedMemoryTabName"
/>
</div>
</div>
</template>
</template>
...
...
src/views/personal-space/personal-app-setting/components/app-setting.vue
View file @
491141b5
...
@@ -80,6 +80,7 @@ const generateAgentAvatarLoading = ref(false) // 是否正在生成图片
...
@@ -80,6 +80,7 @@ const generateAgentAvatarLoading = ref(false) // 是否正在生成图片
const
generatePreambleLoading
=
ref
(
false
)
// 是否正在生成开场白
const
generatePreambleLoading
=
ref
(
false
)
// 是否正在生成开场白
const
generateFeaturedQuestionsLoading
=
ref
(
false
)
// 是否正在生成推荐词
const
generateFeaturedQuestionsLoading
=
ref
(
false
)
// 是否正在生成推荐词
const
isShowMemoryVariableModal
=
ref
(
false
)
//是否显示记忆变量弹窗
const
isShowMemoryVariableModal
=
ref
(
false
)
//是否显示记忆变量弹窗
const
isOpenLongMemory
=
ref
(
personalAppConfigStore
.
commConfig
.
isLongMemory
===
'Y'
)
const
personalAppFormRef
=
ref
<
FormInst
|
null
>
(
null
)
const
personalAppFormRef
=
ref
<
FormInst
|
null
>
(
null
)
const
agentSystemInputRef
=
ref
<
InputInst
|
null
>
(
null
)
const
agentSystemInputRef
=
ref
<
InputInst
|
null
>
(
null
)
...
@@ -141,6 +142,13 @@ watch(
...
@@ -141,6 +142,13 @@ watch(
{
deep
:
true
},
{
deep
:
true
},
)
)
watch
(
()
=>
personalAppConfigStore
.
commConfig
.
isLongMemory
,
(
newValue
)
=>
{
isOpenLongMemory
.
value
=
newValue
===
'Y'
},
)
onMounted
(
async
()
=>
{
onMounted
(
async
()
=>
{
if
(
router
.
currentRoute
.
value
.
params
.
agentId
)
{
if
(
router
.
currentRoute
.
value
.
params
.
agentId
)
{
isInitGetAgentAppDetail
.
value
=
true
isInitGetAgentAppDetail
.
value
=
true
...
@@ -473,26 +481,28 @@ function handleShowMemoryVariableModal() {
...
@@ -473,26 +481,28 @@ function handleShowMemoryVariableModal() {
}
}
function
handleDeleteMemoryVariableItem
(
memoryVariable
:
object
)
{
function
handleDeleteMemoryVariableItem
(
memoryVariable
:
object
)
{
window
.
$dialog
.
warning
({
window
.
$message
title
:
'删除提示'
,
.
ctWarning
(
content
:
'删除后不可撤销。如应用已发布,更新发布后该应用的用户无法使用该记忆变量,是否继续?'
,
t
(
positiveText
:
'确定'
,
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable_delete_tip_content'
,
negativeText
:
'取消'
,
),
onPositiveClick
:
()
=>
{
t
(
'common_module.delete_tip_title'
),
personalAppConfigStore
.
updatePersonalAppConfigState
({
)
commConfig
:
{
.
then
(()
=>
{
...
personalAppConfigStore
.
commConfig
,
if
(
personalAppConfigStore
.
commConfig
.
variableStructure
!==
null
)
{
variableStructure
:
personalAppConfigStore
.
commConfig
.
variableStructure
.
filter
(
const
updatedVariableStructure
=
personalAppConfigStore
.
commConfig
.
variableStructure
.
filter
(
(
variable
)
=>
variable
!==
memoryVariable
,
(
variable
)
=>
variable
!==
memoryVariable
,
),
)
},
personalAppConfigStore
.
updatePersonalAppConfigState
({
})
commConfig
:
{
window
.
$message
.
success
(
'删除成功'
)
...
personalAppConfigStore
.
commConfig
,
},
variableStructure
:
updatedVariableStructure
.
length
>
0
?
updatedVariableStructure
:
null
,
onNegativeClick
:
()
=>
{
},
window
.
$message
.
success
(
'已取消'
)
})
},
}
})
window
.
$message
.
success
(
t
(
'common_module.delete_success_message'
))
})
}
}
function
handleAddMemoryVariable
()
{
function
handleAddMemoryVariable
()
{
...
@@ -505,7 +515,18 @@ function handleAddMemoryVariable() {
...
@@ -505,7 +515,18 @@ function handleAddMemoryVariable() {
function
handleCopyMemoryVariableName
(
memoryVariableItem
:
MemoryVariableForm
)
{
function
handleCopyMemoryVariableName
(
memoryVariableItem
:
MemoryVariableForm
)
{
copyToClip
(
memoryVariableItem
.
key
)
copyToClip
(
memoryVariableItem
.
key
)
window
.
$message
.
success
(
'成功复制名称'
)
window
.
$message
.
success
(
t
(
'common_module.copy_success_message'
))
}
function
handleChangeMemoryFragmentState
(
value
:
boolean
)
{
const
LongMemoryValue
=
value
?
'Y'
:
'N'
personalAppConfigStore
.
updatePersonalAppConfigState
({
commConfig
:
{
...
personalAppConfigStore
.
commConfig
,
isLongMemory
:
LongMemoryValue
,
},
})
isOpenLongMemory
.
value
=
LongMemoryValue
===
'Y'
}
}
</
script
>
</
script
>
...
@@ -982,9 +1003,9 @@ function handleCopyMemoryVariableName(memoryVariableItem: MemoryVariableForm) {
...
@@ -982,9 +1003,9 @@ function handleCopyMemoryVariableName(memoryVariableItem: MemoryVariableForm) {
<
template
#
arrow
>
<
template
#
arrow
>
<RightOne
theme=
"multi-color"
size=
"17"
:fill=
"['#333', '#333', '#333', '#333']"
/>
<RightOne
theme=
"multi-color"
size=
"17"
:fill=
"['#333', '#333', '#333', '#333']"
/>
</
template
>
</
template
>
<NCollapseItem
name=
"
pream
ble"
class=
"my-[13px]!"
>
<NCollapseItem
name=
"
memoryVaria
ble"
class=
"my-[13px]!"
>
<
template
#
header
>
<
template
#
header
>
<span
class=
"w-[60px]"
>
{{
<span
class=
"
mr-[5px]
w-[60px]"
>
{{
t
(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable'
)
t
(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable'
)
}}
</span>
}}
</span>
<n-popover
trigger=
"hover"
placement=
"top-start"
class=
"p-[12px]! left-[-120px]!"
:show-arrow=
"false"
>
<n-popover
trigger=
"hover"
placement=
"top-start"
class=
"p-[12px]! left-[-120px]!"
:show-arrow=
"false"
>
...
@@ -1094,6 +1115,55 @@ function handleCopyMemoryVariableName(memoryVariableItem: MemoryVariableForm) {
...
@@ -1094,6 +1115,55 @@ function handleCopyMemoryVariableName(memoryVariableItem: MemoryVariableForm) {
</div>
</div>
<div
class=
"flex flex-1 flex-wrap items-center gap-[12px] overflow-hidden"
></div>
<div
class=
"flex flex-1 flex-wrap items-center gap-[12px] overflow-hidden"
></div>
</NCollapseItem>
</NCollapseItem>
<NCollapseItem
name=
"memoryFragment"
class=
"my-[13px]!"
>
<
template
#
header
>
<span
class=
"mr-[5px] w-[60px]"
>
{{
t
(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_fragment'
)
}}
</span>
<n-popover
trigger=
"hover"
placement=
"top-start"
class=
"p-[12px]! left-[-120px]!"
:show-arrow=
"false"
>
<template
#
trigger
>
<Help
theme=
"outline"
size=
"15"
fill=
"#333"
:stroke-width=
"2"
class=
"mt-[2px]"
/>
</
template
>
<div
class=
"w-[650px] text-[14px]"
>
<div
class=
"m-w-[100%] mb-[16px] mt-[0px] leading-[22px]"
>
{{
t(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_fragment_message',
)
}}
</div>
<div>
<img
src=
"@/assets/images/memory-fragment.png"
width=
"650"
height=
"206"
/>
</div>
</div>
</n-popover>
</template>
<
template
#
header-extra
>
<n-switch
v-model:value=
"isOpenLongMemory"
size=
"small"
@
update:value=
"handleChangeMemoryFragmentState"
>
<template
#
checked
>
{{
t
(
'common_module.open'
)
}}
</
template
>
<
template
#
unchecked
>
{{
t
(
'common_module.close'
)
}}
</
template
>
</n-switch>
</template>
<div>
<div
class=
"mb-[16px] text-xs text-[#84868c]"
>
{{
t(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_fragment_content',
)
}}
</div>
<div
class=
"flex flex-1 flex-wrap items-center gap-[12px] overflow-hidden"
></div>
</div>
</NCollapseItem>
</NCollapse>
</NCollapse>
</div>
</div>
</section>
</section>
...
...
src/views/personal-space/personal-app-setting/components/memory-preview-modal.vue
View file @
491141b5
This diff is collapsed.
Click to expand it.
src/views/personal-space/personal-app-setting/components/memory-variable-modal.vue
View file @
491141b5
...
@@ -4,6 +4,7 @@ import { nextTick, ref, shallowReadonly, watch } from 'vue'
...
@@ -4,6 +4,7 @@ import { nextTick, ref, shallowReadonly, watch } from 'vue'
import
{
usePersonalAppConfigStore
}
from
'@/store/modules/personal-app-config'
import
{
usePersonalAppConfigStore
}
from
'@/store/modules/personal-app-config'
import
{
FormInst
,
FormItemRule
,
FormRules
}
from
'naive-ui'
import
{
FormInst
,
FormItemRule
,
FormRules
}
from
'naive-ui'
import
{
useI18n
}
from
'vue-i18n'
import
{
useI18n
}
from
'vue-i18n'
import
{
cloneDeep
}
from
'lodash-es'
export
interface
MemoryVariableForm
{
export
interface
MemoryVariableForm
{
key
:
string
key
:
string
...
@@ -66,18 +67,28 @@ watch(
...
@@ -66,18 +67,28 @@ watch(
()
=>
personalAppConfigStore
.
commConfig
.
variableStructure
,
()
=>
personalAppConfigStore
.
commConfig
.
variableStructure
,
(
newValue
)
=>
{
(
newValue
)
=>
{
if
(
newValue
!==
null
)
{
if
(
newValue
!==
null
)
{
memoryVariableTable
.
value
=
JSON
.
parse
(
JSON
.
stringify
(
newValue
))
memoryVariableTable
.
value
=
cloneDeep
(
newValue
)
}
else
{
memoryVariableTable
.
value
=
[]
}
}
},
},
{
immediate
:
true
},
{
immediate
:
true
},
)
)
function
handlePreviewModalClose
(
refresh
=
false
)
{
function
handle
Memory
PreviewModalClose
(
refresh
=
false
)
{
isShowMemoryVariableModal
.
value
=
false
isShowMemoryVariableModal
.
value
=
false
memoryVariableTable
.
value
=
refresh
memoryVariableTable
.
value
=
refresh
?
memoryVariableTable
.
value
?
memoryVariableTable
.
value
:
JSON
.
parse
(
JSON
.
stringify
(
personalAppConfigStore
.
commConfig
.
variableStructure
))
:
personalAppConfigStore
.
commConfig
.
variableStructure
memoryVariableTable
.
value
=
memoryVariableTable
.
value
.
filter
((
item
)
=>
item
.
key
)
?
cloneDeep
(
personalAppConfigStore
.
commConfig
.
variableStructure
)
:
[]
if
(
Array
.
isArray
(
memoryVariableTable
.
value
))
{
memoryVariableTable
.
value
=
memoryVariableTable
.
value
.
filter
((
item
)
=>
item
.
key
)
}
else
{
memoryVariableTable
.
value
=
[]
}
}
}
function
handleMemoryVariableFormSave
()
{
function
handleMemoryVariableFormSave
()
{
...
@@ -99,7 +110,7 @@ function handleMemoryVariableFormSave() {
...
@@ -99,7 +110,7 @@ function handleMemoryVariableFormSave() {
if
(
isAllValid
)
{
if
(
isAllValid
)
{
personalAppConfigStore
.
commConfig
.
variableStructure
=
memoryVariableTable
.
value
personalAppConfigStore
.
commConfig
.
variableStructure
=
memoryVariableTable
.
value
handlePreviewModalClose
(
true
)
handle
Memory
PreviewModalClose
(
true
)
window
.
$message
.
success
(
t
(
'common_module.save_success_message'
))
window
.
$message
.
success
(
t
(
'common_module.save_success_message'
))
}
else
{
}
else
{
window
.
$message
.
error
(
t
(
'common_module.save_fail_message'
))
window
.
$message
.
error
(
t
(
'common_module.save_fail_message'
))
...
@@ -149,7 +160,13 @@ defineExpose({
...
@@ -149,7 +160,13 @@ defineExpose({
)
)
}}
</span
}}
</span
>
>
<Close
theme=
"outline"
size=
"18"
fill=
"#00000073"
class=
"cursor-pointer"
@
click=
"handlePreviewModalClose()"
/>
<Close
theme=
"outline"
size=
"18"
fill=
"#00000073"
class=
"cursor-pointer"
@
click=
"handleMemoryPreviewModalClose()"
/>
</div>
</div>
<div
<div
class=
"mb-[12px] mt-[16px] flex items-center justify-center rounded-[4px] bg-[#FFF4E6] px-[15px] pb-[3px] pt-[4px]"
class=
"mb-[12px] mt-[16px] flex items-center justify-center rounded-[4px] bg-[#FFF4E6] px-[15px] pb-[3px] pt-[4px]"
...
@@ -227,7 +244,7 @@ defineExpose({
...
@@ -227,7 +244,7 @@ defineExpose({
</th>
</th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody
v-if=
"memoryVariableTable.length !== 0"
>
<tr
v-for=
"(item, index) in memoryVariableTable"
:key=
"index"
>
<tr
v-for=
"(item, index) in memoryVariableTable"
:key=
"index"
>
<td
class=
"pl-[12px]"
>
<td
class=
"pl-[12px]"
>
<n-form
<n-form
...
@@ -292,7 +309,7 @@ defineExpose({
...
@@ -292,7 +309,7 @@ defineExpose({
/>
/>
</n-form-item>
</n-form-item>
</td>
</td>
<td
class=
"ml-[15px] mt-[
10
px] flex pl-[12px] pt-[10px]"
>
<td
class=
"ml-[15px] mt-[
5
px] flex pl-[12px] pt-[10px]"
>
<n-tooltip
trigger=
"hover"
>
<n-tooltip
trigger=
"hover"
>
<
template
#
trigger
>
<
template
#
trigger
>
<Delete
<Delete
...
@@ -309,10 +326,48 @@ defineExpose({
...
@@ -309,10 +326,48 @@ defineExpose({
</td>
</td>
</tr>
</tr>
</tbody>
</tbody>
<tbody
v-else
>
<tr>
<td
colspan=
"3"
>
<div
class=
"flex h-[286px] flex-col items-center"
>
<img
src=
"@/assets/images/empty.png"
width=
"235px"
height=
"160px"
/>
<div
class=
"text-[18px]"
>
{{
t(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable_modal.none_memory_variable',
)
}}
</div>
<div
class=
"mt-[12px] text-[14px] text-[#84868c]"
>
{{
t(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable_modal.add_variable_message',
)
}}
</div>
<div
class=
"text-theme-color mt-[6px] flex w-[78px] cursor-pointer"
@
click=
"handleAddMemoryVariableItem"
>
<Plus
theme=
"outline"
size=
"22"
:stroke-width=
"2"
class=
"text-theme-color"
/>
<span>
{{
t(
'personal_space_module.agent_module.agent_setting_module.agent_config_module.memory_variable_modal.memory_variable_add_now',
)
}}
</span>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</table>
</div>
</div>
</n-scrollbar>
</n-scrollbar>
<div
class=
"text-theme-color mt-[16px] flex w-[78px] cursor-pointer"
@
click=
"handleAddMemoryVariableItem"
>
<div
v-show=
"memoryVariableTable.length !== 0"
class=
"text-theme-color mt-[16px] flex w-[78px] cursor-pointer"
@
click=
"handleAddMemoryVariableItem"
>
<Plus
theme=
"outline"
size=
"22"
:stroke-width=
"2"
class=
"text-theme-color"
/>
<Plus
theme=
"outline"
size=
"22"
:stroke-width=
"2"
class=
"text-theme-color"
/>
<span>
{{
<span>
{{
t(
t(
...
@@ -323,7 +378,7 @@ defineExpose({
...
@@ -323,7 +378,7 @@ defineExpose({
<div
class=
"mt-[24px] flex justify-end"
>
<div
class=
"mt-[24px] flex justify-end"
>
<button
<button
class=
"hover:text-theme-color hover:border-theme-color !mr-[12px] box-content !h-[38px] !w-[74px] cursor-pointer rounded-[6px] border-[1px] border-solid border-[#dde3f0] px-[10px] outline-none transition-all duration-300 hover:border-[theme-color]"
class=
"hover:text-theme-color hover:border-theme-color !mr-[12px] box-content !h-[38px] !w-[74px] cursor-pointer rounded-[6px] border-[1px] border-solid border-[#dde3f0] px-[10px] outline-none transition-all duration-300 hover:border-[theme-color]"
@
click=
"handlePreviewModalClose()"
@
click=
"handle
Memory
PreviewModalClose()"
>
>
{{ t('common_module.cancel_btn_text') }}
{{ t('common_module.cancel_btn_text') }}
</button>
</button>
...
...
types/locales.d.ts
View file @
491141b5
...
@@ -70,6 +70,10 @@ declare namespace I18n {
...
@@ -70,6 +70,10 @@ declare namespace I18n {
collect_unsubscribed
:
string
collect_unsubscribed
:
string
cancel
:
string
cancel
:
string
preservation
:
string
preservation
:
string
open
:
string
close
:
string
delete_tip_title
:
string
wipe_data
:
string
dialogue_module
:
{
dialogue_module
:
{
continue_question_message
:
string
continue_question_message
:
string
...
@@ -244,6 +248,11 @@ declare namespace I18n {
...
@@ -244,6 +248,11 @@ declare namespace I18n {
memory_variable_action_copy
:
string
memory_variable_action_copy
:
string
variable_name
:
string
variable_name
:
string
variable_value
:
string
variable_value
:
string
memory_fragment
:
string
memory_fragment_message
:
string
memory_fragment_content
:
string
memory_variable_delete_tip_content
:
string
memory_fragment_delete_all_tip_content
:
string
memory_variable_modal
:
{
memory_variable_modal
:
{
edit_memory_variable
:
string
edit_memory_variable
:
string
...
@@ -259,6 +268,9 @@ declare namespace I18n {
...
@@ -259,6 +268,9 @@ declare namespace I18n {
default_value_placeholder
:
string
default_value_placeholder
:
string
name_placeholder
:
string
name_placeholder
:
string
add_variable
:
string
add_variable
:
string
memory_variable_add_now
:
string
none_memory_variable
:
string
add_variable_message
:
string
memory_variable_rules
:
{
memory_variable_rules
:
{
name_not_null
:
string
name_not_null
:
string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment