Public/Get-OpenAIClient.ps1
function Get-OpenAIClient { param( [string]$apikey = $env:OPENAI_API_KEY, [string]$endpoint = $env:OPENAI_API_ENDPOINT, [string]$model = $env:OPENAI_API_MODEL, [string]$apiVersion = $env:OPENAI_API_VERSION ) if (!$apikey) { throw "OpenAI API Key is required" } if (!$endpoint) { throw "OpenAI API Endpoint is required" } if (!$model) { $model = "gpt-4o" } if (($endpoint -match "azure") -and !$apiVersion) { $apiVersion = "2024-05-01-preview" } return [OpenAIClient]::new($apikey, $endpoint, $model, $apiVersion) } # SIG # Begin signature block # MIIc+AYJKoZIhvcNAQcCoIIc6TCCHOUCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDCWA68PoEce0zE # EPCsUNMtH0zDi6zUY5OdVW/qV/G6N6CCAyowggMmMIICDqADAgECAhBcsg5m3zM9 # kUZxmeNzIQNjMA0GCSqGSIb3DQEBCwUAMCoxKDAmBgNVBAMMH0NIRU5YSVpIQU5H # IC0gQ29kZSBTaWduaW5nIENlcnQwIBcNMjQwMTA4MTMwMjA0WhgPMjA5OTEyMzEx # NjAwMDBaMCoxKDAmBgNVBAMMH0NIRU5YSVpIQU5HIC0gQ29kZSBTaWduaW5nIENl # cnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDKDY3QG81JOKZG9jTb # QriDMDhq6gy93Pmoqgav9wErj+CgVvXKk+lGpUu74MWVyLUrJx8/ACb4b287wsXx # mQj8zQ3SqGn5CCjPKoAPsSbry0LOSl8bsFpwBr3YBJVL6cibhus2KLCbNu/u7sND # wyivKXYA1Iy1uTQPNVPcBx36krZTZyyE4CmngO75YbTMEzvHEjM3BIXdKtEt673t # iNOVSP6doh0zRwWEh2Y/eoOpv+FUokORwhKonxMtmIIET+ZPx7Ex+9aqH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