From b600c0c13fa6dee7fbea53ef0a618d9485ac5ce5 Mon Sep 17 00:00:00 2001 From: Rodrigo Ribeiro Gomes Date: Thu, 14 Nov 2024 23:08:11 -0300 Subject: [PATCH] Fix google provider minor bug due implementation of image support --- powershai/providers/google.ps1 | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/powershai/providers/google.ps1 b/powershai/providers/google.ps1 index 52a0f8f..31d2bcc 100644 --- a/powershai/providers/google.ps1 +++ b/powershai/providers/google.ps1 @@ -511,17 +511,21 @@ function ConvertTo-GoogleContentMessage { # default conversion! $MsgPart = @() - foreach($content in $MsgContent){ - if($content.text){ - $MsgPart += @{ text = $content.text } - } - - if($content.type -eq "image_url" -and $content.image_url.url -match 'data:(.+?);base64,(.+)'){ - $MimeType = $matches[1]; - $Base64 = $matches[2]; - $MsgPart += @{ inlineData = @{ mimeType = $MimeType; data = $Base64 }} + if($MsgContent -is [string]){ + $MsgPart += @{ text = $MsgContent } + } else { + foreach($content in $MsgContent){ + if($content.text){ + $MsgPart += @{ text = $content.text } + } + + if($content.type -eq "image_url" -and $content.image_url.url -match 'data:(.+?);base64,(.+)'){ + $MimeType = $matches[1]; + $Base64 = $matches[2]; + $MsgPart += @{ inlineData = @{ mimeType = $MimeType; data = $Base64 }} + } + } - } switch($m.role){