Skip to content

Commit d28295d

Browse files
authored
refactor: If the recommendation question fails, it can be retrieved again. (#516)
1 parent 1fb1ae6 commit d28295d

File tree

7 files changed

+93
-7
lines changed

7 files changed

+93
-7
lines changed

frontend/src/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@
184184
"chart_selected": "Selected {0}"
185185
},
186186
"qa": {
187+
"retrieve_error": "Model recommendation failed...",
188+
"retrieve_again": "Retrieve Again",
187189
"recently": "recently",
188190
"recommend": "recommend",
189191
"quick_question": "quick question",

frontend/src/i18n/ko-KR.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@
184184
"chart_selected": "{0}개 선택됨"
185185
},
186186
"qa": {
187+
"retrieve_error": "모델 추천 문제 실패...",
188+
"retrieve_again": "다시 가져오기",
187189
"recently": "최근",
188190
"recommend": "추천",
189191
"quick_question": "빠른 질문",

frontend/src/i18n/zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@
184184
"chart_selected": "已选{0}"
185185
},
186186
"qa": {
187+
"retrieve_error": "模型推荐问题失败...",
188+
"retrieve_again": "重新获取",
187189
"recently": "最近",
188190
"recommend": "推荐",
189191
"quick_question": "快捷提问",

frontend/src/views/chat/QuickQuestion.vue

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
<script lang="ts" setup>
22
import { ref } from 'vue'
33
import icon_quick_question from '@/assets/svg/icon_quick_question.svg'
4-
import { Close } from '@element-plus/icons-vue'
4+
import icon_close from '@/assets/svg/operate/ope-close.svg'
5+
import icon_replace_outlined from '@/assets/svg/icon_replace_outlined.svg'
56
import RecommendQuestion from '@/views/chat/RecommendQuestion.vue'
67
import { ChatInfo } from '@/api/chat.ts'
78
import RecentQuestion from '@/views/chat/RecentQuestion.vue'
89
const activeName = ref('recommend')
910
const recommendQuestionRef = ref()
11+
const recentQuestionRef = ref()
1012
const popoverRef = ref()
1113
const getRecommendQuestions = () => {
1214
recommendQuestionRef.value.getRecommendQuestions()
1315
}
16+
17+
const retrieveQuestions = () => {
18+
getRecommendQuestions()
19+
recentQuestionRef.value.getRecentQuestions()
20+
}
1421
const quickAsk = (question: string) => {
1522
emits('quickAsk', question)
1623
hiddenProps()
@@ -59,7 +66,18 @@ const props = withDefaults(
5966
trigger="click"
6067
:width="320"
6168
>
62-
<el-icon class="close_icon"><Close @click="hiddenProps" /></el-icon>
69+
<el-button class="tool-btn close_icon" text @click="hiddenProps">
70+
<el-icon size="18">
71+
<icon_close />
72+
</el-icon>
73+
</el-button>
74+
<el-tooltip effect="dark" :offset="8" :content="$t('qa.retrieve_again')" placement="top">
75+
<el-button class="tool-btn refresh_icon" text :disabled="disabled" @click="retrieveQuestions">
76+
<el-icon size="18">
77+
<icon_replace_outlined />
78+
</el-icon>
79+
</el-button>
80+
</el-tooltip>
6381
<el-tabs v-model="activeName" class="quick_question_tab">
6482
<el-tab-pane :label="$t('qa.recommend')" name="recommend">
6583
<RecommendQuestion
@@ -76,7 +94,13 @@ const props = withDefaults(
7694
/>
7795
</el-tab-pane>
7896
<el-tab-pane v-if="datasourceId" :label="$t('qa.recently')" name="recently">
79-
<RecentQuestion :datasource-id="datasourceId" @click-question="quickAsk"> </RecentQuestion>
97+
<RecentQuestion
98+
ref="recentQuestionRef"
99+
:disabled="disabled"
100+
:datasource-id="datasourceId"
101+
@click-question="quickAsk"
102+
>
103+
</RecentQuestion>
80104
</el-tab-pane>
81105
</el-tabs>
82106
<template #reference>
@@ -95,6 +119,11 @@ const props = withDefaults(
95119
.quick_question_tab {
96120
height: 230px;
97121
}
122+
.ed-tab-pane {
123+
display: flex;
124+
align-items: normal;
125+
width: 100%;
126+
}
98127
.ed-tabs__content {
99128
overflow: auto;
100129
}
@@ -106,9 +135,38 @@ const props = withDefaults(
106135
.close_icon {
107136
position: absolute;
108137
cursor: pointer;
109-
top: 12px;
110-
right: 12px;
138+
top: 4px;
139+
right: 4px;
111140
}
141+
142+
.refresh_icon {
143+
position: absolute;
144+
cursor: pointer;
145+
top: 30px;
146+
right: 4px;
147+
z-index: 1;
148+
}
149+
150+
.tool-btn {
151+
font-size: 14px;
152+
font-weight: 400;
153+
line-height: 22px;
154+
color: rgba(100, 106, 115, 1);
155+
156+
.tool-btn-inner {
157+
display: flex;
158+
flex-direction: row;
159+
align-items: center;
160+
}
161+
162+
&:hover {
163+
background: rgba(31, 35, 41, 0.1);
164+
}
165+
&:active {
166+
background: rgba(31, 35, 41, 0.1);
167+
}
168+
}
169+
112170
.ed-tabs__item {
113171
font-size: 14px;
114172
height: 38px;

frontend/src/views/chat/RecentQuestion.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import { chatApi } from '@/api/chat.ts'
55
const props = withDefaults(
66
defineProps<{
77
datasourceId?: number
8+
disabled?: boolean
89
}>(),
910
{
1011
datasourceId: undefined,
12+
disabled: false,
1113
}
1214
)
1315
@@ -29,6 +31,9 @@ async function getRecentQuestions() {
2931
computedQuestions.value = res
3032
})
3133
}
34+
defineExpose({
35+
getRecentQuestions,
36+
})
3237
</script>
3338

3439
<template>
@@ -38,6 +43,7 @@ async function getRecentQuestions() {
3843
v-for="(question, index) in computedQuestions"
3944
:key="index"
4045
class="question"
46+
:class="{ disabled: disabled }"
4147
@click="clickQuestion(question)"
4248
>
4349
{{ question }}
@@ -49,6 +55,7 @@ async function getRecentQuestions() {
4955
<style scoped lang="less">
5056
.recent-questions {
5157
height: 100%;
58+
width: 100%;
5259
overflow-x: hidden;
5360
overflow-y: auto;
5461
font-size: 14px;

frontend/src/views/chat/RecommendQuestion.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,14 @@ defineExpose({ getRecommendQuestions, id: () => props.recordId, stop })
186186
</div>
187187
</div>
188188
</div>
189+
<div v-else-if="position === 'input'" class="recommend-questions-error">
190+
{{ $t(qa.retrieve_error) }}
191+
</div>
189192
</template>
190193

191194
<style scoped lang="less">
192195
.recommend-questions {
196+
width: 100%;
193197
font-size: 14px;
194198
font-weight: 500;
195199
line-height: 22px;
@@ -231,4 +235,15 @@ defineExpose({ getRecommendQuestions, id: () => props.recordId, stop })
231235
}
232236
}
233237
}
238+
239+
.recommend-questions-error {
240+
font-size: 12px;
241+
font-weight: 500;
242+
color: rgba(100, 106, 115, 1);
243+
margin-top: 70px;
244+
display: flex;
245+
align-items: center;
246+
justify-content: center;
247+
width: 100%;
248+
}
234249
</style>

frontend/src/views/system/prompt/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ const typeChange = (val: any) => {
528528
<template #icon>
529529
<icon_add_outlined></icon_add_outlined>
530530
</template>
531-
{{ $t('prompt.add_prompt_word') }}
531+
{{ $t('prompt.add_prompt_word') }}11
532532
</el-button>
533533
</div>
534534
</div>
@@ -619,7 +619,7 @@ const typeChange = (val: any) => {
619619
<template #icon>
620620
<icon_add_outlined></icon_add_outlined>
621621
</template>
622-
{{ $t('prompt.add_prompt_word') }}
622+
{{ $t('prompt.add_prompt_word') }}22
623623
</el-button>
624624
</div>
625625
</template>

0 commit comments

Comments
 (0)