LI
liupeirong/powershell-copilot
A command line tool to generate PowerShell commands from natural language.
Introduction
This is a command line tool that lets you type in natural language and generates PowerShell commands which you can decide to run.
It's inspired by the Codex Cli sample and has been refactored
from deprecated Codex models to GPT models with chat completion APIs.
How to set it up?
You only need to set it up once.
- Open PowerShell as an administrator, and run the following command:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser- Clone this repo to your machine, to a folder <REPO_ROOT>.
- Run the following command in <REPO_ROOT>:
.\scripts\powershell_setup.ps1- Edit <REPO_ROOT>\config.ini to put in your Azure OpenAI configuration.
- Set an environment variable called
AZURE_OPENAI_API_KEYat each start up of your PowerShell $PROFILE. - Install Python 3.8+.
- Run the following command in <REPO_ROOT>:
pip install -r .\requirements.txtHow to run?
- Open a new PowerShell console.
- Type in
#followed by your question in natural language in one line. HitCtrl + gwhen you are done.
If there's no error, Azure OpenAI will generate a PowerShell command. If you like the command, hit enter to run it.
Otherwise hit Ctrl + C to quit.
How to customize?
- You can customize system prompt in
<REPO_ROOT>\contexts\system_prompt.txt. - You can customize few-shot examples in
<REPO_ROOT>\contexts\examples.txt.
Limitations
- Chat history is not yet implemented.