Skip to content

Commit

Permalink
Fix google provider minor bug due implementation of image support
Browse files Browse the repository at this point in the history
  • Loading branch information
rrg92 committed Nov 15, 2024
1 parent 6da0552 commit b600c0c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions powershai/providers/google.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down

0 comments on commit b600c0c

Please sign in to comment.