diff --git a/PSAI.psd1 b/PSAI.psd1 index 6e6e355..0a3ace0 100644 --- a/PSAI.psd1 +++ b/PSAI.psd1 @@ -1,10 +1,10 @@ @{ RootModule = 'PSAI.psm1' - ModuleVersion = '0.4.11' + ModuleVersion = '0.5.0' GUID = '68662d19-a8f1-484f-b1b7-3bf0e8a436df' Author = 'Douglas Finke' CompanyName = 'Doug Finke' - Copyright = '© 2024 All rights reserved.' + Copyright = '© 2025 All rights reserved.' Description = @' PSAI brings OpenAI ChatGPT to PowerShell, leveraging advanced AI capabilities in your PowerShell scripts for dynamic, intelligent automation and data processing diff --git a/Private/Invoke-OAIBeta.ps1 b/Private/Invoke-OAIBeta.ps1 index 4ca2e76..d4ba4ec 100644 --- a/Private/Invoke-OAIBeta.ps1 +++ b/Private/Invoke-OAIBeta.ps1 @@ -58,6 +58,12 @@ function Invoke-OAIBeta { 'AzureOpenAI' { $headers['api-key'] = "$($AzOAISecrets.apiKEY)" + if (-not [string]::IsNullOrEmpty($AzOAISecrets.organizationId)) { + $headers['OpenAI-Organization'] = "$($AzOAISecrets.organizationId)" + } + else { + $headers.Remove('OpenAI-Organization') + } if ($Body -isnot [System.IO.Stream]) { if ($null -ne $Body -and $Body.Contains("model") ) { diff --git a/Public/Set-AzOAISecrets.ps1 b/Public/Set-AzOAISecrets.ps1 index fd85ef9..7769105 100644 --- a/Public/Set-AzOAISecrets.ps1 +++ b/Public/Set-AzOAISecrets.ps1 @@ -12,15 +12,20 @@ The URI of the Azure OAI. The API key for accessing the Azure OAI. .PARAMETER apiVersion -The version of the Azure OAI. +The version of the Azure OAI in YYYY-MM-DD format. .PARAMETER deploymentName -The name of the deployment. +The name of the AI model deployment. + +.PARAMETER organizationId +The organization ID associated with the Azure OAI. This parameter is optional. .EXAMPLE -Set-AzOAISecrets -apiURI "https://api.example.com" -apiKEY "myApiKey" -apiVersion "v1" -deploymentName "MyDeployment" +Set-AzOAISecrets -apiURI "https://api.example.com" -apiKEY "myApiKey" -apiVersion "2024-10-21" -deploymentName "MyDeployment" Sets the Azure OAI secrets with the specified values. +.NOTES +See https://learn.microsoft.com/en-us/azure/ai-foundry/openai/reference for more information on Azure OpenAI API version #> function Set-AzOAISecrets { @@ -33,11 +38,15 @@ function Set-AzOAISecrets { [Parameter(Mandatory)] $apiVersion, [Parameter(Mandatory)] - $deploymentName + $deploymentName, + [Parameter(Mandatory = $false)] + [ValidateNotNullOrEmpty()] + $organizationId = $null ) $script:AzOAISecrets['apiURI'] = $apiURI $script:AzOAISecrets['apiKEY'] = $apiKEY $script:AzOAISecrets['apiVersion'] = $apiVersion $script:AzOAISecrets['deploymentName'] = $deploymentName + $script:AzOAISecrets['organizationId'] = $organizationId } \ No newline at end of file diff --git a/README.md b/README.md index ab5d36d..1237a80 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,13 @@ Then set `$env:OpenAIKey` to your key. After creating an [Azure OpenAI resource](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=web-portal), you can use the `PSAI` module to interact with it. -You need to get the following secrets form the Azure Portal and Azure AI Studio - `apiURI`,`apiVersion`,`apiKey`,`deploymentName`. + +You need to get the following secrets from the Azure Portal and Azure AI Studio: +- `apiURI` +- `apiVersion` +- `apiKey` +- `deploymentName` +- *(Optional)* `organizationId` (if your Azure OpenAI resource requires the `OpenAI-Organization` header) ```powershell $secrets = @{ @@ -67,12 +73,15 @@ $secrets = @{ apiKey = "" apiVersion = "" deploymentName = "" + organizationId = "" # Optional } Set-OAIProvider AzureOpenAI Set-AzOAISecrets @secrets ``` +If your Azure OpenAI implementation requires the `OpenAI-Organization` header, provide the `organizationId` value. Otherwise, you can omit it. + ## Usage The full set of functions can be found here https://github.com/dfinke/PSAI/wiki/ diff --git a/changelog.md b/changelog.md index 4831fd0..4e786f0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,9 @@ +## v0.4.12 + +Thank you to https://github.com/jmkloz for the PR! + +- Added optional `organizationId` parameter to `Set-AzOAISecrets` for Azure OpenAI support +- `Invoke-OAIBeta` now sets the `OpenAI-Organization` header when `organizationId` is provided ## v0.4.11