Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active August 10, 2024 17:18
Show Gist options
  • Save dfinke/c0e7efa41e4ffd1aa790945ce5c3bbde to your computer and use it in GitHub Desktop.
Save dfinke/c0e7efa41e4ffd1aa790945ce5c3bbde to your computer and use it in GitHub Desktop.
AI-powered image comparison in PowerShell using PSAI module
# Install-module PSAI
# Get OpenAI API key from https://platform.openai.com/account/api-keys
# Set $env:OpenAIKey
function Compare-PicsUsingAI {
param(
$pic1,
$pic2
)
$f1 = Invoke-OAIUploadFile -Path $pic1
$f2 = Invoke-OAIUploadFile -Path $pic2
$ToolResources = @{
code_interpreter = @{
file_ids = @($f1.id, $f2.id)
}
}
$assistant = New-OAIAssistant -ToolResources $ToolResources -Tools (Enable-OAICodeInterpreter)
Invoke-SimpleQuestion -AssistantId $assistant.id -Question "Compare these two images, are they duplicates?"
$null = Clear-OAIAllItems
}
$pic1 = "$PSScriptRoot\01-BioPic.png"
$pic2 = "$PSScriptRoot\02-BioPic.png"
# Compare-PicsUsingAI $pic1 $pic2
Compare-PicsUsingAI $pic2 $pic2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment