Giter Site home page Giter Site logo

powershellai's Introduction

Unleash the Power of Artificial Intelligence with PowerShell

Welcome to the PowerShell Artificial Intelligence repository! Here, you will find a collection of powerful PowerShell scripts that will enable you to easily integrate AI into your projects and take them to the next level. Imagine being able to interact directly with OpenAI's GPT AI with just a few simple commands. With this module, it's now possible.

Get Ahead of the Game

By using this module, you'll have the ability to add cutting-edge AI functionality to your projects without needing to have a deep understanding of the underlying technology. This means you can stay focused on what you do best while still being able to work with the latest and greatest.

Start Your AI Journey Today

Installation

In the PowerShell console:

Install-Module -Name PowerShellAI

Get/Create your OpenAI API key from https://beta.openai.com/account/api-keys and then set $env:OpenAIKey.

Examples

Check out these PowerShell scripts to see how easy it is to get started with AI in PowerShell:

PS Script Description Location
Disable-AIShortCutKey Disable the ctrl+g shortcut key go getting completions Disable-AIShortCutKey.ps1
Enable-AIShortCutKey Enable the ctrl+g Enable-AIShortCutKey.ps1
Get-OpenAIEdit Given a prompt and an instruction, the model will return an edited version of the prompt Get-OpenAIEdit.ps1
Get-GPT3Completion Get a completion from the OpenAI GPT-3 API Get-GPT3Completion.ps1
Get-DalleImage Get an image from the OpenAI DALL-E API Get-DalleImage.ps1
ai Experimental AI function that you can pipe all sorts of things into and get back a completion ai.ps1
copilot Makes the request to GPT, parses the response and displays it in a box and then prompts the user to run the code or not. copilot.ps1
Get-DalleImage Get an image from the OpenAI DALL-E API Get-DalleImage.ps1
Set-DalleImageAsWallpaper Set the image from the OpenAI DALL-E API as the wallpaper Set-DalleImageAsWallpaper.ps1

Demos of the PowerShellAI

Here are some vidoes of PowerShellAI in action:

Description YouTube Video
Quick Demo of PowerShellAI
Using PowerShell with OpenAI GPT in the console with a shortcut key
PowerShell AI - copilot at the command line
PowerShell AI - new ai function
New-Spreadsheet script: PowerShell + ChatGPT + Excel


What it looks like

Note: You can use the gpt alias for Get-GPT3Completion

Get-GPT3Completion "list of planets only names as json"

[
    "Mercury",
    "Venus",
    "Earth",
    "Mars",
    "Jupiter",
    "Saturn",
    "Uranus",
    "Neptune"
]

As XML

Get-GPT3Completion "list of planets only names as xml"


<?xml version="1.0" encoding="UTF-8"?>
<planets>
  <planet>Mercury</planet>
  <planet>Venus</planet>
  <planet>Earth</planet>
  <planet>Mars</planet>
  <planet>Jupiter</planet>
  <planet>Saturn</planet>
  <planet>Uranus</planet>
  <planet>Neptune</planet>
</planets>

As Markdown

 Get-GPT3Completion "first 5 US presidents and terms as markdown table"


| President | Term |
|----------|------|
| George Washington | 1789-1797 |
| John Adams | 1797-1801 |
| Thomas Jefferson | 1801-1809 |
| James Madison | 1809-1817 |
| James Monroe | 1817-1825 |

Copy and pasted into this README.md:

President Term
George Washington 1789-1797
John Adams 1797-1801
Thomas Jefferson 1801-1809
James Madison 1809-1817
James Monroe 1817-1825

ai function

The ai function calls that allows piping and prompting text. This is useful for chaining commands together.

ai "list of planets only names as json"
[
    "Mercury",
    "Venus",
    "Earth",
    "Mars",
    "Jupiter",
    "Saturn",
    "Uranus",
    "Neptune"
]
ai "list of planets only names as json" | ai 'convert to  xml'
<?xml version="1.0" encoding="UTF-8"?>
<Planets>
    <Planet>Mercury</Planet>
    <Planet>Venus</Planet>
    <Planet>Earth</Planet>
    <Planet>Mars</Planet>
    <Planet>Jupiter</Planet>
    <Planet>Saturn</Planet>
    <Planet>Uranus</Planet>
    <Planet>Neptune</Planet>
</Planets>
ai "list of planets only names as json" | ai 'convert to  xml' | ai 'convert to  powershell'
[xml]$xml = @"
<?xml version="1.0" encoding="UTF-8"?>
<Planets>
    <Planet>Mercury</Planet>
    <Planet>Venus</Planet>
    <Planet>Earth</Planet>
    <Planet>Mars</Planet>
    <Planet>Jupiter</Planet>
    <Planet>Saturn</Planet>
    <Planet>Uranus</Planet>
    <Planet>Neptune</Planet>
</Planets>
"@

$xml.Planets.Planet

Use ai with git

Pipe the output of git status to ai to create a commit message.

git status | ai "create a detailed git message"
Commit message:
Added PowerShellAI.psd1, README.md, changelog.md, and Public/ai.ps1 to dcf-spike-piping-to-ai-function branch. Updated PowerShellAI.psd1 and README.md with new changes. Added changelog.md to track changes. Added Public/ai.ps1 to enable piping to AI function.

Copilot at the PowerShell Console

Thank you to Clem Messerli for posting a great prompt to show copilot in action.

Alt text

Check out the video of copilot in action

Code editing example

Unlike completions, edits takes two inputs: the text to edit and an instruction. Here the model is set to code-davinci-edit-001 because we're working with PowerShell code.

  • Here you're passing in the string that is a PowerShell function.
  • The instruction is to add a comment-based help detailed description
Get-OpenAIEdit @'
function greet {
    param($n)

    "Hello $n"
}
'@ -Instruction 'add comment-based help detailed description' -model 'code-davinci-edit-001'

The GPT AI returns:

<#
    .SYNOPSIS
        Greet someone
    .DESCRIPTION
        This function greets someone
    .PARAMETER n
        The name of the person to greet
    .EXAMPLE
        greet -n "John"
    .NOTES
        This is a note
#>
function greet {
    param($n)

    "Hello $n"
}

DALL-E

The DALL-E API is a new API from OpenAI that allows you to generate images from text. The API is currently in beta and is free to use.

Use this function to generate an image from text and set it as your desktop background.

Set-DalleImageAsBackground "A picture of a cat"

You can also use the Get-DalleImage function to get the image and it saves to a temp file, ready to use.

Get-DalleImage "A picture of a cat" 

powershellai's People

Contributors

dfinke avatar skatterbrainz avatar dwaynegibbs avatar martynkeigher avatar pjgeutjens avatar stahler avatar ajansveld avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.