dfinke / PSAI

PowerShell AI module. Brings OpenAI to the console and scripts
MIT License
80 stars 9 forks source link

Update module to support Azure Open AI Assistant uris #11

Closed Agazoth closed 3 months ago

Agazoth commented 3 months ago

The Url string for Open AI and Azure Open AI are not identical. The Azure Open AI the Url is always suffixed with the api-version parameter and the baseurl must match the deployment.

This branch introduces a Get-OAIEndpoint cmdlet that has been introduced to all cmdlets, where $url = $baseurl + was found. It takes care of compiling the correct url for the call combining endpoint data nad parameters.

The module in this branch has been tested on Azure Open AI and it returns proper answers.

The module has not been tested properly on Open AI. When running on Open AI with my old apy set to $env:OpenAIKey it just returns the question, but runs without errors. Same issue as described here: https://github.com/dfinke/PSAI/issues/9

dfinke commented 3 months ago

Thanks for the PR. Here is what I was using to go against Azure OAI.

I am planning a new release with all the new features OpenAI has made recently.

Then the plan is to do a sweep on the Az OAI config.

$secrets = @{
    apiURI         = "https://openai-gpt4-latest.openai.azure.com"
    apiVersion     = "2024-02-15-preview"
    apiKey         = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    deploymentName = "gpt4-latest"
}

Set-OAIProvider AzureOpenAI
Set-AzOAISecrets @secrets
Agazoth commented 3 months ago

@dfinke - Azure OpenAI works with these adapted changes