Skip to content

Commit

Permalink
fix: frontend handle sometimes server not generate the wrong follow u…
Browse files Browse the repository at this point in the history
…p data struct (langgenius#7916)
  • Loading branch information
iamjoel committed Sep 3, 2024
1 parent 0cfcc97 commit 7fdd964
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 10 additions & 5 deletions web/app/components/base/chat/chat/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,16 @@ export const useChat = (
handleUpdateChatList(newChatList)
}
if (config?.suggested_questions_after_answer?.enabled && !hasStopResponded.current && onGetSuggestedQuestions) {
const { data }: any = await onGetSuggestedQuestions(
responseItem.id,
newAbortController => suggestedQuestionsAbortControllerRef.current = newAbortController,
)
setSuggestQuestions(data)
try {
const { data }: any = await onGetSuggestedQuestions(
responseItem.id,
newAbortController => suggestedQuestionsAbortControllerRef.current = newAbortController,
)
setSuggestQuestions(data)
}
catch (e) {
setSuggestQuestions([])
}
}
},
onFile(file) {
Expand Down
15 changes: 10 additions & 5 deletions web/app/components/workflow/panel/debug-and-preview/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,16 @@ export const useChat = (
}

if (config?.suggested_questions_after_answer?.enabled && !hasStopResponded.current && onGetSuggestedQuestions) {
const { data }: any = await onGetSuggestedQuestions(
responseItem.id,
newAbortController => suggestedQuestionsAbortControllerRef.current = newAbortController,
)
setSuggestQuestions(data)
try {
const { data }: any = await onGetSuggestedQuestions(
responseItem.id,
newAbortController => suggestedQuestionsAbortControllerRef.current = newAbortController,
)
setSuggestQuestions(data)
}
catch (error) {
setSuggestQuestions([])
}
}
},
onMessageEnd: (messageEnd) => {
Expand Down

0 comments on commit 7fdd964

Please sign in to comment.