yzwijsen / chatgpt-powershell

example on how to use the chatGPT api with powershell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ€– ChatGPT PowerShell Scripts πŸš€

GitHub license

This repository contains two PowerShell scripts that allow you to interact with OpenAI's ChatGPT 🧠:

  1. ChatGPT-Conversation.ps1: Engage in a conversational manner with ChatGPT using a command-line interface.
  2. ChatGPT-One-Shot.ps1: Provide a rough email draft or message and receive a professionally written response in three different levels of formality.

Both scripts serve as simple examples on how to use ChatGPT's API with PowerShell.

βš™οΈ Requirements

  • PowerShell
  • An API key for OpenAI's API

πŸ› οΈ Setup

  1. Clone or download this repository to your local machine.
  2. Replace <your API key> in both scripts with your OpenAI API key πŸ”‘.

πŸš€ Usage

ChatGPT-Conversation.ps1

  1. Open PowerShell and navigate to the folder containing the script πŸ“.
  2. Execute the script: .\ChatGPT-Conversation.ps1 πŸ–₯️.
  3. You'll see a welcome message and a prompt to enter your question or command 🎀.
  4. Type your question or command and press Enter ⌨️.
  5. The AI will respond with its output πŸ’¬.
  6. To exit the script, type exit and press Enter πŸšͺ.
  7. To reset the conversation and start a new one, type reset and press Enter πŸ”„.

ChatGPT-One-Shot.ps1

  1. Open PowerShell and navigate to the folder containing the script πŸ“.
  2. Execute the script: .\ChatGPT-One-Shot.ps1 πŸ–₯️.
  3. Provide a rough email draft or message when prompted πŸ“.
  4. The AI will respond with three separate professionally written answers ranging from informal, formal, to business formal πŸ’¬.
  5. Press Enter to exit the script πŸšͺ.

πŸ“– Examples

ChatGPT-Conversation.ps1

ChatGPT-Conversation

ChatGPT-One-Shot.ps1

ChatGPT-One-Shot

πŸ“ Notes

The scripts initialize the AI with a default system message. You can change this message to set a different context for the AI by modifying the $AiSystemMessage variable. ChatGPT-Conversation.ps1 will keep track of the conversation history, allowing the AI to provide context-aware answers.

About

example on how to use the chatGPT api with powershell

License:MIT License


Languages

Language:PowerShell 100.0%