File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -202,9 +202,24 @@ export async function generateAnswersWithChatgptApiCompat(
202202 console . debug ( 'No choice in response data for reasoning model' )
203203 return
204204 }
205- const content = choice . message ?. content ?? choice . text
205+ let content = choice . message ?. content ?? choice . text
206+ if ( Array . isArray ( content ) ) {
207+ // Prefer output_text segments; fallback to any string content
208+ const parts = content
209+ . map ( ( p ) => {
210+ if ( typeof p === 'string' ) return p
211+ if ( p && typeof p === 'object' ) {
212+ if ( typeof p . output_text === 'string' ) return p . output_text
213+ if ( typeof p . text === 'string' ) return p . text
214+ }
215+ return ''
216+ } )
217+ . filter ( Boolean )
218+ content = parts . join ( '' )
219+ }
206220 if ( content !== undefined && content !== null ) {
207- answer = content
221+ answer = String ( content )
222+ }
208223 port . postMessage ( { answer, done : false , session : null } )
209224 }
210225 if ( choice . finish_reason || content !== undefined ) {
You can’t perform that action at this time.
0 commit comments