File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
packages/gitbook/src/components/Search Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -167,16 +167,16 @@ function AnswerBody(props: { answer: AskAnswerResult }) {
167
167
'dark:text-light/8' ,
168
168
) }
169
169
>
170
- { answer . hasAnswer ? answer . body : t ( language , 'search_ask_no_answer' ) }
170
+ { answer . body ?? t ( language , 'search_ask_no_answer' ) }
171
171
{ answer . followupQuestions . length > 0 ? (
172
172
< AnswerFollowupQuestions followupQuestions = { answer . followupQuestions } />
173
173
) : null }
174
174
</ div >
175
175
{ answer . sources . length > 0 ? (
176
176
< AnswerSources
177
- hasAnswer = { answer . hasAnswer }
178
177
sources = { answer . sources }
179
178
language = { language }
179
+ hasAnswer = { Boolean ( answer . body ) }
180
180
/>
181
181
) : null }
182
182
</ >
@@ -233,7 +233,7 @@ function AnswerFollowupQuestions(props: { followupQuestions: string[] }) {
233
233
function AnswerSources ( props : {
234
234
sources : AskAnswerSource [ ] ;
235
235
language : TranslationLanguage ;
236
- hasAnswer ? : boolean ;
236
+ hasAnswer : boolean ;
237
237
} ) {
238
238
const { sources, language, hasAnswer } = props ;
239
239
Original file line number Diff line number Diff line change @@ -40,10 +40,10 @@ export interface AskAnswerSource {
40
40
}
41
41
42
42
export interface AskAnswerResult {
43
+ /** Undefined if no answer. */
43
44
body ?: React . ReactNode ;
44
45
followupQuestions : string [ ] ;
45
46
sources : AskAnswerSource [ ] ;
46
- hasAnswer : boolean ;
47
47
}
48
48
49
49
/**
@@ -181,7 +181,12 @@ export const streamAskQuestion = streamResponse(async function* (
181
181
182
182
const spaceData = new Map < string , RevisionPage [ ] > ( ) ;
183
183
for await ( const chunk of stream ) {
184
- yield transformAnswer ( chunk . answer , spaceData ) ;
184
+ if ( ! chunk ) {
185
+ continue ;
186
+ }
187
+
188
+ const encoded = await transformAnswer ( chunk . answer , spaceData ) ;
189
+ yield encoded ;
185
190
}
186
191
} ) ;
187
192
@@ -223,7 +228,7 @@ async function transformAnswer(
223
228
const { pages } = await api . getSpaceContentData ( { spaceId } , undefined ) ;
224
229
spaceData . set ( spaceId , pages ) ;
225
230
} ,
226
- { concurrency : 3 } ,
231
+ { concurrency : 1 } ,
227
232
) ;
228
233
229
234
const sources = answer . sources
@@ -267,7 +272,6 @@ async function transformAnswer(
267
272
) : null ,
268
273
followupQuestions : answer . followupQuestions ,
269
274
sources,
270
- hasAnswer : ! ! answer . answer && 'document' in answer . answer ,
271
275
} ;
272
276
}
273
277
You can’t perform that action at this time.
0 commit comments