• Documentation •
The OpenAI PowerShell module provides convenient access to the OpenAI APIs from the console and from PowerShell scripts.
As of June 19, 2024
This release supports the latest OpenAI API changes. Here's what's new:
more to come ...
https://github.com/dfinke/PSAI/wiki
Install-Module -Name PSAI -Scope CurrentUser -Force
Get/Create your OpenAI API key from https://platform.openai.com/account/api-keys.
Then set $env:OpenAIKey
to your key.
The full set of functions can be found here https://github.com/dfinke/PSAI/wiki/
Invoke-OAIChat 'How do I output all files in a directory PowerShell?'
To output all files in a directory using PowerShell, you can use the Get-ChildItem
cmdlet. Here's an example of how you can do it:
Get-ChildItem -Path "C:\Path\To\Directory" -File
Replace "C:\Path\To\Directory"
with the path to the directory whose files you want to output. This command will list only files in the specified directory.
If you want to list all files, including files in subdirectories, you can add the -Recurse
parameter to Get-ChildItem
:
Get-ChildItem -Path "C:\Path\To\Directory" -File -Recurse
This command will recursively list all files in the specified directory and its subdirectories.
Run either of these commands in PowerShell to output all files in a directory.
After creating an Azure OpenAI resource, 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
.
$secrets = @{
apiURI = "<Your Azure OpenAI API URI>"
apiVersion = "<Your Azure OpenAI API Version>"
apiKey = "<Your Azure OpenAI API Key>"
deploymentName = "<Your Azure OpenAI Deployment Name>"
}
Set-OAIProvider AzureOpenAI
Set-AzOAISecrets @secrets