File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ const transformGenerationConfig = (params: Params) => {
7878 thinkingConfig [ 'thinking_budget' ] = params . thinking . budget_tokens ;
7979 generationConfig [ 'thinking_config' ] = thinkingConfig ;
8080 }
81+ if ( params . modalities ) {
82+ generationConfig [ 'responseModalities' ] = params . modalities . map ( ( modality ) =>
83+ modality . toUpperCase ( )
84+ ) ;
85+ }
8186 return generationConfig ;
8287} ;
8388
@@ -425,6 +430,10 @@ export const GoogleChatCompleteConfig: ProviderConfig = {
425430 param : 'generationConfig' ,
426431 transform : ( params : Params ) => transformGenerationConfig ( params ) ,
427432 } ,
433+ modalities : {
434+ param : 'generationConfig' ,
435+ transform : ( params : Params ) => transformGenerationConfig ( params ) ,
436+ } ,
428437} ;
429438
430439export interface GoogleErrorResponse {
@@ -447,6 +456,10 @@ interface GoogleResponseCandidate {
447456 text ?: string ;
448457 thought ?: string ; // for models like gemini-2.0-flash-thinking-exp refer: https://ai.google.dev/gemini-api/docs/thinking-mode#streaming_model_thinking
449458 functionCall ?: GoogleGenerateFunctionCall ;
459+ inlineData ?: {
460+ mimeType : string ;
461+ data : string ;
462+ } ;
450463 } [ ] ;
451464 } ;
452465 logprobsResult ?: {
@@ -560,6 +573,13 @@ export const GoogleChatCompleteResponseTransform: (
560573 content = part . text ;
561574 contentBlocks . push ( { type : 'text' , text : part . text } ) ;
562575 }
576+ } else if ( part . inlineData ) {
577+ contentBlocks . push ( {
578+ type : 'image_url' ,
579+ image_url : {
580+ url : `data:${ part . inlineData . mimeType } ;base64,${ part . inlineData . data } ` ,
581+ } ,
582+ } ) ;
563583 }
564584 }
565585
You can’t perform that action at this time.
0 commit comments