Last active
August 10, 2024 17:18
-
-
Save dfinke/c0e7efa41e4ffd1aa790945ce5c3bbde to your computer and use it in GitHub Desktop.
AI-powered image comparison in PowerShell using PSAI module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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