Skip to content

Commit 0776c11

Browse files
authored
Fix some issues for Summarize and rate several responses in action bar (#505)
* Fix undefined props warning * Add try catch to handle invalid parameter name * Fix template parameters dialog not show in release build
1 parent ca8841f commit 0776c11

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

src/components/ChatSetting.vue

+23-12
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@
9494
<template v-slot:append-inner>
9595
<v-btn
9696
flat
97-
v-bind="props"
9897
size="x-small"
9998
icon="mdi-help"
10099
style="background-color: inherit"
101-
@click="isShowTemplateGuideDialog = !isShowTemplateGuideTooltip"
100+
@click="
101+
isShowTemplateParametersDialog = !isShowTemplateGuideTooltip
102+
"
102103
>
103104
</v-btn>
104105
</template>
@@ -138,11 +139,11 @@
138139
</v-dialog>
139140
<v-dialog
140141
width="auto"
141-
:model-value="isShowTemplateGuideDialog"
142-
v-on:after-leave="isShowTemplateGuideDialog = false"
142+
:model-value="isShowTemplateParametersDialog"
143+
v-on:after-leave="isShowTemplateParametersDialog = false"
143144
>
144145
<v-card>
145-
<v-md-preview class="pa-4" :text="$t('chat.actionTemplateGuide')" />
146+
<v-md-preview class="pa-4" :text="templateParametersInfo" />
146147
</v-card>
147148
</v-dialog>
148149
<ConfirmModal ref="confirmModal" />
@@ -170,7 +171,13 @@ const prefix = ref("");
170171
const template = ref("");
171172
const suffix = ref("");
172173
const previewRef = ref("");
173-
const isShowTemplateGuideDialog = ref(false);
174+
const templateParametersInfo = `
175+
#### ${i18n.global.t("chat.templateParameters")}:
176+
| ${i18n.global.t("chat.parameter")}|${i18n.global.t("chat.description")}|
177+
|-|-|
178+
|{botName}|${i18n.global.t("chat.botNameDesc")}|
179+
|{botResponse}|${i18n.global.t("chat.botResponseDesc")}|`;
180+
const isShowTemplateParametersDialog = ref(false);
174181
const store = useStore();
175182
const userActions = computed(() => {
176183
return store.state.actions.filter((p) => !p.hide);
@@ -308,12 +315,16 @@ function edit(item) {
308315
}
309316
310317
async function onInputTemplate() {
311-
previewRef.value = await preview(
312-
prefix.value,
313-
template.value,
314-
suffix.value,
315-
previewSampleData,
316-
);
318+
try {
319+
previewRef.value = await preview(
320+
prefix.value,
321+
template.value,
322+
suffix.value,
323+
previewSampleData,
324+
);
325+
} catch (error) {
326+
previewRef.value = `Error:\n${error.message}`;
327+
}
317328
}
318329
319330
async function addEditAction() {

src/i18n/locales/en.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
"preview": "Preview",
6565
"inNewChat": "in new chat",
6666
"inCurrentChat": "in current chat",
67-
"actionTemplateGuide": "#### Template Parameters:\n| Parameter | Description |\n|---------------|-------------------------------------|\n| {botName} | name of the selected response’s bot |\n| {botResponse} | the selected response |\n"
67+
"templateParameters": "Template Parameters",
68+
"parameter": "Parameter",
69+
"description": "Description",
70+
"botNameDesc": "name of the selected response’s bot",
71+
"botResponseDesc": "the selected response"
6872
},
6973
"bot": {
7074
"creatingConversation": "Creating conversation...",

src/i18n/locales/zh.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@
6464
"preview": "预览",
6565
"inNewChat": "在新对话",
6666
"inCurrentChat": "在当前对话",
67-
"actionTemplateGuide": "#### 模板参数:\n| 参数 | 描述 |\n|-----------|-----------------------------------| \n| {botName} | 所选响应的机器人名称 |\n| {botResponse} | 所选响应内容 |\n"
67+
"templateParameters": "模板参数",
68+
"parameter": "参数",
69+
"description": "描述",
70+
"botNameDesc": "所选响应的机器人名称",
71+
"botResponseDesc": "所选响应内容"
6872
},
6973
"bot": {
7074
"creatingConversation": "创建新对话...",

0 commit comments

Comments
 (0)