refactor: Recommended questions display ten by default.

This commit is contained in:
wangjiahao
2025-12-01 16:52:41 +08:00
committed by xuwei-fit2cloud
parent a4e0a43ebe
commit 2b13dc7f93
7 changed files with 24 additions and 12 deletions
+6 -2
View File
@@ -328,8 +328,12 @@ export const chatApi = {
predict: (record_id: number | undefined, controller?: AbortController) => {
return request.fetchStream(`/chat/record/${record_id}/predict`, {}, controller)
},
recommendQuestions: (record_id: number | undefined, controller?: AbortController) => {
return request.fetchStream(`/chat/recommend_questions/${record_id}`, {}, controller)
recommendQuestions: (
record_id: number | undefined,
controller?: AbortController,
params: any
) => {
return request.fetchStream(`/chat/recommend_questions/${record_id}${params}`, {}, controller)
},
recentQuestions: (datasource_id?: number): Promise<any> => {
return request.get(`/chat/recent_questions/${datasource_id}`)
+1 -1
View File
@@ -11,7 +11,7 @@ const recommendQuestionRef = ref()
const recentQuestionRef = ref()
const popoverRef = ref()
const getRecommendQuestions = () => {
recommendQuestionRef.value.getRecommendQuestions()
recommendQuestionRef.value.getRecommendQuestions(10)
}
const retrieveQuestions = () => {
@@ -58,12 +58,13 @@ function clickQuestion(question: string): void {
const stopFlag = ref(false)
async function getRecommendQuestions() {
async function getRecommendQuestions(articles_number: number) {
stopFlag.value = false
loading.value = true
try {
const controller: AbortController = new AbortController()
const response = await chatApi.recommendQuestions(props.recordId, controller)
const params = articles_number ? '?articles_number=' + articles_number : ''
const response = await chatApi.recommendQuestions(props.recordId, controller, params)
const reader = response.body.getReader()
const decoder = new TextDecoder('utf-8')