@@ -206,14 +206,14 @@ export const mcpToolDefinitions: ChatCompletionTool[] = [
206206 } ,
207207 image_url : {
208208 type : 'string' ,
209- description : 'URL of the image to analyze'
209+ description : 'URL of the image to analyze. If omitted, the most recent image in the chat will be used. '
210210 } ,
211211 model : {
212212 type : 'string' ,
213213 description : 'Optional vision model to use (default: glm-4.6v)'
214214 }
215215 } ,
216- required : [ 'prompt' , 'image_url' ]
216+ required : [ 'prompt' ]
217217 }
218218 }
219219 }
@@ -387,7 +387,7 @@ async function executeYoutubeTranscribe(
387387 'Authorization' : `Bearer ${ apiKey } ` ,
388388 'Content-Type' : 'application/json'
389389 } ,
390- body : JSON . stringify ( { url } )
390+ body : JSON . stringify ( { urls : [ url ] } )
391391 } ) ;
392392
393393 if ( ! response . ok ) {
@@ -399,7 +399,21 @@ async function executeYoutubeTranscribe(
399399
400400 let resultText = `YouTube transcript for: ${ url } \n\n` ;
401401
402- if ( data . transcript ) {
402+ // Handle new API response format (array of transcripts)
403+ if ( data . transcripts && Array . isArray ( data . transcripts ) && data . transcripts . length > 0 ) {
404+ const result = data . transcripts [ 0 ] ;
405+ if ( result . success && result . transcript ) {
406+ const transcript = result . transcript . slice ( 0 , 8000 ) ;
407+ resultText += transcript ;
408+ if ( result . transcript . length > 8000 ) {
409+ resultText += `\n... (transcript truncated, ${ result . transcript . length } chars total)` ;
410+ }
411+ } else {
412+ return { success : false , result : '' , error : result . error || 'Failed to retrieve transcript' } ;
413+ }
414+ }
415+ // Fallback for potential legacy/singular response format
416+ else if ( data . transcript ) {
403417 const transcript = data . transcript . slice ( 0 , 8000 ) ;
404418 resultText += transcript ;
405419 if ( data . transcript . length > 8000 ) {
@@ -411,6 +425,8 @@ async function executeYoutubeTranscribe(
411425 if ( data . text . length > 8000 ) {
412426 resultText += `\n... (transcript truncated, ${ data . text . length } chars total)` ;
413427 }
428+ } else {
429+ return { success : false , result : '' , error : 'No transcript found in response' } ;
414430 }
415431
416432 return { success : true , result : resultText } ;
0 commit comments