├── .devcontainer.json ├── README.md ├── OpenAI-Samples ├── powershell-bug-fixer.ipynb ├── classification.ipynb ├── airport-code-extractor.ipynb ├── create-interview-questions.ipynb ├── extract-contact-information.ipynb ├── calculate-time-complexity.ipynb ├── powershell-to-natural-language.ipynb ├── extract-keywords.ipynb ├── explain-code.ipynb └── chatgpt-hiking-recommendations.ipynb └── Azure-OpenAI-Samples └── airport-code-extractor.azure.ipynb /.devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "mcr.microsoft.com/dotnet/sdk:7.0", 3 | "customizations":{ 4 | "vscode": { 5 | "extensions": [ 6 | "ms-dotnettools.dotnet-interactive-vscode", 7 | "ms-vscode.powershell" 8 | ] 9 | } 10 | }, 11 | // "containerEnv": { 12 | // "AOAI_DEPLOYMENTID": "", 13 | // "AOAI_ENDPOINT": "", 14 | // "AOAI_KEY": "" 15 | // }, 16 | // "postStartCommand": "bash download-vocab-files.sh", 17 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenAI/Azure OpenAI PowerShell Samples 2 | 3 | [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/dfinke/openai-powershell-samples?quickstart=1) 4 | 5 | Collection of OpenAI/Azure OpenAI samples written using the [PowerShell AI module](https://github.com/dfinke/PowerShellAI). Similar to the [OpenAI dotnet samples](https://github.com/Azure-Samples/openai-dotnet-samples). 6 | 7 | **📤 One-click setup**: [Open a new Codespace](https://codespaces.new/dfinke/openai-powershell-samples), giving you a fully configured cloud environment. 8 | 9 | 18 | 19 | ## Prerequisites 20 | 21 | - [Azure Account](https://aka.ms/free) 22 | - Access to [Azure OpenAI](https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal) or [OpenAI](https://openai.com/) 23 | - [VS Code](https://code.visualstudio.com/Download) 24 | - [Polyglot Noteboks VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) 25 | 26 | ## Examples 27 | 28 | ### Generation 29 | 30 | - [Airport code extractor](./OpenAI-Samples/airport-code-extractor.ipynb) 31 | - [Calculate time complexity](./OpenAI-Samples/calculate-time-complexity.ipynb) 32 | - [Create interview questions](./OpenAI-Samples/create-interview-questions.ipynb) 33 | - [Extract contact information](./OpenAI-Samples/extract-contact-information.ipynb) 34 | 35 | 36 | ### Classification 37 | 38 | - [Classification](./OpenAI-Samples/classification.ipynb) 39 | - [Extract keywords](./OpenAI-Samples/extract-keywords.ipynb) 40 | 41 | ### Code 42 | 43 | - [Explain code](./OpenAI-Samples/explain-code.ipynb) 44 | - [Powershell to natural language](./OpenAI-Samples/powershell-to-natural-language.ipynb) 45 | - [Powershell bug fixer](./OpenAI-Samples/powershell-bug-fixer.ipynb) -------------------------------------------------------------------------------- /OpenAI-Samples/powershell-bug-fixer.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Create interview questions\n", 9 | "\n", 10 | "Create interview questions.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "Create a list of 8 questions for my interview with a science fiction author:\n", 28 | "```" 29 | ] 30 | }, 31 | { 32 | "attachments": {}, 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "## Install PowerShellAI" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": null, 42 | "metadata": { 43 | "dotnet_interactive": { 44 | "language": "pwsh" 45 | }, 46 | "polyglot_notebook": { 47 | "kernelName": "pwsh" 48 | } 49 | }, 50 | "outputs": [], 51 | "source": [ 52 | "if(Get-Module -list PowerShellAI) {\n", 53 | " \"PowerShellAI is already installed\"\n", 54 | "} \n", 55 | "else {\n", 56 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 57 | "}" 58 | ] 59 | }, 60 | { 61 | "cell_type": "markdown", 62 | "metadata": {}, 63 | "source": [ 64 | "## Set OpenAI Key\n", 65 | "\n", 66 | " Get yours here: https://platform.openai.com/account/api-keys" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": { 73 | "dotnet_interactive": { 74 | "language": "pwsh" 75 | }, 76 | "polyglot_notebook": { 77 | "kernelName": "pwsh" 78 | } 79 | }, 80 | "outputs": [ 81 | { 82 | "name": "stdout", 83 | "output_type": "stream", 84 | "text": [ 85 | "OpenAIKey is already set\r\n" 86 | ] 87 | } 88 | ], 89 | "source": [ 90 | "if(!$env:OpenAIKey) {\n", 91 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 92 | "}\n", 93 | "else {\n", 94 | " \"OpenAIKey is already set\"\n", 95 | "}" 96 | ] 97 | }, 98 | { 99 | "attachments": {}, 100 | "cell_type": "markdown", 101 | "metadata": {}, 102 | "source": [ 103 | "## Define Prompt" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": 2, 109 | "metadata": { 110 | "dotnet_interactive": { 111 | "language": "pwsh" 112 | }, 113 | "polyglot_notebook": { 114 | "kernelName": "pwsh" 115 | } 116 | }, 117 | "outputs": [], 118 | "source": [ 119 | "$prompt = @'\n", 120 | "# Fix bugs in the code below\n", 121 | "\n", 122 | "# Buggy Code\n", 123 | "function AddTwoNumbers($num1, $num2)\n", 124 | "{\n", 125 | " $result = $num1 + $num2\n", 126 | "}\n", 127 | "\n", 128 | "# Fixed code\n", 129 | "'@" 130 | ] 131 | }, 132 | { 133 | "attachments": {}, 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "## Ask GPT" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 3, 143 | "metadata": { 144 | "dotnet_interactive": { 145 | "language": "pwsh" 146 | }, 147 | "polyglot_notebook": { 148 | "kernelName": "pwsh" 149 | } 150 | }, 151 | "outputs": [ 152 | { 153 | "name": "stdout", 154 | "output_type": "stream", 155 | "text": [ 156 | "\r\n", 157 | "function AddTwoNumbers($num1, $num2)\r\n", 158 | "{\r\n", 159 | " $result = $num1 + $num2;\r\n", 160 | " return $result;\r\n", 161 | "}\r\n" 162 | ] 163 | } 164 | ], 165 | "source": [ 166 | "gpt $prompt" 167 | ] 168 | } 169 | ], 170 | "metadata": { 171 | "kernelspec": { 172 | "display_name": ".NET (PowerShell)", 173 | "language": "PowerShell", 174 | "name": ".net-pwsh" 175 | }, 176 | "language_info": { 177 | "name": "polyglot-notebook" 178 | }, 179 | "polyglot_notebook": { 180 | "kernelInfo": { 181 | "defaultKernelName": "pwsh", 182 | "items": [ 183 | { 184 | "aliases": [], 185 | "languageName": "pwsh", 186 | "name": "pwsh" 187 | } 188 | ] 189 | } 190 | } 191 | }, 192 | "nbformat": 4, 193 | "nbformat_minor": 2 194 | } 195 | -------------------------------------------------------------------------------- /OpenAI-Samples/classification.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Classification\n", 9 | "\n", 10 | "Classify items into categories via example.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "The following is a list of companies and the categories they fall into:\n", 28 | "\n", 29 | "Apple, Facebook, Fedex\n", 30 | "\n", 31 | "Apple\n", 32 | "Category:\n", 33 | "```" 34 | ] 35 | }, 36 | { 37 | "attachments": {}, 38 | "cell_type": "markdown", 39 | "metadata": {}, 40 | "source": [ 41 | "## Install PowerShellAI" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 1, 47 | "metadata": { 48 | "dotnet_interactive": { 49 | "language": "pwsh" 50 | }, 51 | "polyglot_notebook": { 52 | "kernelName": "pwsh" 53 | } 54 | }, 55 | "outputs": [ 56 | { 57 | "name": "stdout", 58 | "output_type": "stream", 59 | "text": [ 60 | "PowerShellAI is already installed\r\n" 61 | ] 62 | } 63 | ], 64 | "source": [ 65 | "if(Get-Module -list PowerShellAI) {\n", 66 | " \"PowerShellAI is already installed\"\n", 67 | "} \n", 68 | "else {\n", 69 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 70 | "}" 71 | ] 72 | }, 73 | { 74 | "cell_type": "markdown", 75 | "metadata": {}, 76 | "source": [ 77 | "## Set OpenAI Key\n", 78 | "\n", 79 | " Get yours here: https://platform.openai.com/account/api-keys" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": { 86 | "dotnet_interactive": { 87 | "language": "pwsh" 88 | }, 89 | "polyglot_notebook": { 90 | "kernelName": "pwsh" 91 | } 92 | }, 93 | "outputs": [ 94 | { 95 | "name": "stdout", 96 | "output_type": "stream", 97 | "text": [ 98 | "OpenAIKey is already set\r\n" 99 | ] 100 | } 101 | ], 102 | "source": [ 103 | "if(!$env:OpenAIKey) {\n", 104 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 105 | "}\n", 106 | "else {\n", 107 | " \"OpenAIKey is already set\"\n", 108 | "}" 109 | ] 110 | }, 111 | { 112 | "attachments": {}, 113 | "cell_type": "markdown", 114 | "metadata": {}, 115 | "source": [ 116 | "## Define Prompt" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": 2, 122 | "metadata": { 123 | "dotnet_interactive": { 124 | "language": "pwsh" 125 | }, 126 | "polyglot_notebook": { 127 | "kernelName": "pwsh" 128 | } 129 | }, 130 | "outputs": [], 131 | "source": [ 132 | "$prompt = @'\n", 133 | "The following is a list of companies and the categories they fall into:\n", 134 | "\n", 135 | "Apple, Facebook, Fedex\n", 136 | "\n", 137 | "Apple\n", 138 | "Category:\n", 139 | "'@" 140 | ] 141 | }, 142 | { 143 | "attachments": {}, 144 | "cell_type": "markdown", 145 | "metadata": {}, 146 | "source": [ 147 | "## Ask GPT" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 3, 153 | "metadata": { 154 | "dotnet_interactive": { 155 | "language": "pwsh" 156 | }, 157 | "polyglot_notebook": { 158 | "kernelName": "pwsh" 159 | } 160 | }, 161 | "outputs": [ 162 | { 163 | "name": "stdout", 164 | "output_type": "stream", 165 | "text": [ 166 | " Technology\r\n", 167 | "\r\n", 168 | "Facebook\r\n", 169 | "Category: Social Media\r\n", 170 | "\r\n", 171 | "Fedex\r\n", 172 | "Category: Logistics and Delivery\r\n" 173 | ] 174 | } 175 | ], 176 | "source": [ 177 | "gpt $prompt" 178 | ] 179 | } 180 | ], 181 | "metadata": { 182 | "kernelspec": { 183 | "display_name": ".NET (PowerShell)", 184 | "language": "PowerShell", 185 | "name": ".net-pwsh" 186 | }, 187 | "language_info": { 188 | "name": "polyglot-notebook" 189 | }, 190 | "polyglot_notebook": { 191 | "kernelInfo": { 192 | "defaultKernelName": "pwsh", 193 | "items": [ 194 | { 195 | "aliases": [], 196 | "languageName": "pwsh", 197 | "name": "pwsh" 198 | } 199 | ] 200 | } 201 | } 202 | }, 203 | "nbformat": 4, 204 | "nbformat_minor": 2 205 | } 206 | -------------------------------------------------------------------------------- /OpenAI-Samples/airport-code-extractor.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Airport code extractor\n", 9 | "\n", 10 | "A simple prompt for extracting airport codes from text.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "Extract the airport codes from this text:\n", 28 | "\n", 29 | "Text: \"I want to fly from Los Angeles to Miami.\"\n", 30 | "Airport codes: LAX, MIA\n", 31 | "\n", 32 | "Text: \"I want to fly from Orlando to Boston\"\n", 33 | "Airport codes:\n", 34 | "```" 35 | ] 36 | }, 37 | { 38 | "attachments": {}, 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "## Install PowerShellAI" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 1, 48 | "metadata": { 49 | "dotnet_interactive": { 50 | "language": "pwsh" 51 | }, 52 | "polyglot_notebook": { 53 | "kernelName": "pwsh" 54 | } 55 | }, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "PowerShellAI is already installed\r\n" 62 | ] 63 | } 64 | ], 65 | "source": [ 66 | "if(Get-Module -list PowerShellAI) {\n", 67 | " \"PowerShellAI is already installed\"\n", 68 | "} \n", 69 | "else {\n", 70 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 71 | "}" 72 | ] 73 | }, 74 | { 75 | "attachments": {}, 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## Set OpenAI Key\n", 80 | "\n", 81 | " Get yours here: https://platform.openai.com/account/api-keys" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": 2, 87 | "metadata": { 88 | "dotnet_interactive": { 89 | "language": "pwsh" 90 | }, 91 | "polyglot_notebook": { 92 | "kernelName": "pwsh" 93 | } 94 | }, 95 | "outputs": [ 96 | { 97 | "name": "stdout", 98 | "output_type": "stream", 99 | "text": [ 100 | "OpenAIKey is already set\r\n" 101 | ] 102 | } 103 | ], 104 | "source": [ 105 | "if(!$env:OpenAIKey) {\n", 106 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 107 | "}\n", 108 | "else {\n", 109 | " \"OpenAIKey is already set\"\n", 110 | "}" 111 | ] 112 | }, 113 | { 114 | "attachments": {}, 115 | "cell_type": "markdown", 116 | "metadata": {}, 117 | "source": [ 118 | "## Define prompt" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": 3, 124 | "metadata": { 125 | "dotnet_interactive": { 126 | "language": "pwsh" 127 | }, 128 | "polyglot_notebook": { 129 | "kernelName": "pwsh" 130 | } 131 | }, 132 | "outputs": [], 133 | "source": [ 134 | "$prompt = @\"\n", 135 | "Extract the airport codes from this text:\n", 136 | "\n", 137 | "Text: \"I want to fly from Los Angeles to Miami.\"\n", 138 | "Airport codes: LAX, MIA\n", 139 | "\n", 140 | "Text: \"I want to fly from Orlando to Boston\"\n", 141 | "Airport codes:\n", 142 | "\"@" 143 | ] 144 | }, 145 | { 146 | "attachments": {}, 147 | "cell_type": "markdown", 148 | "metadata": {}, 149 | "source": [ 150 | "## Generate completions" 151 | ] 152 | }, 153 | { 154 | "cell_type": "code", 155 | "execution_count": 4, 156 | "metadata": { 157 | "dotnet_interactive": { 158 | "language": "pwsh" 159 | }, 160 | "polyglot_notebook": { 161 | "kernelName": "pwsh" 162 | } 163 | }, 164 | "outputs": [ 165 | { 166 | "name": "stdout", 167 | "output_type": "stream", 168 | "text": [ 169 | " MCO, BOS\r\n" 170 | ] 171 | } 172 | ], 173 | "source": [ 174 | "gpt $prompt # Get-GPT3Completion" 175 | ] 176 | } 177 | ], 178 | "metadata": { 179 | "kernelspec": { 180 | "display_name": ".NET (PowerShell)", 181 | "language": "PowerShell", 182 | "name": ".net-pwsh" 183 | }, 184 | "language_info": { 185 | "name": "polyglot-notebook" 186 | }, 187 | "polyglot_notebook": { 188 | "kernelInfo": { 189 | "defaultKernelName": "pwsh", 190 | "items": [ 191 | { 192 | "aliases": [], 193 | "languageName": "pwsh", 194 | "name": "pwsh" 195 | } 196 | ] 197 | } 198 | } 199 | }, 200 | "nbformat": 4, 201 | "nbformat_minor": 2 202 | } 203 | -------------------------------------------------------------------------------- /OpenAI-Samples/create-interview-questions.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Create interview questions\n", 9 | "\n", 10 | "Create interview questions.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "Create a list of 8 questions for my interview with a science fiction author:\n", 28 | "```" 29 | ] 30 | }, 31 | { 32 | "attachments": {}, 33 | "cell_type": "markdown", 34 | "metadata": {}, 35 | "source": [ 36 | "## Install PowerShellAI" 37 | ] 38 | }, 39 | { 40 | "cell_type": "code", 41 | "execution_count": 1, 42 | "metadata": { 43 | "dotnet_interactive": { 44 | "language": "pwsh" 45 | }, 46 | "polyglot_notebook": { 47 | "kernelName": "pwsh" 48 | } 49 | }, 50 | "outputs": [ 51 | { 52 | "name": "stdout", 53 | "output_type": "stream", 54 | "text": [ 55 | "PowerShellAI is already installed\r\n" 56 | ] 57 | } 58 | ], 59 | "source": [ 60 | "if(Get-Module -list PowerShellAI) {\n", 61 | " \"PowerShellAI is already installed\"\n", 62 | "} \n", 63 | "else {\n", 64 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 65 | "}" 66 | ] 67 | }, 68 | { 69 | "cell_type": "markdown", 70 | "metadata": {}, 71 | "source": [ 72 | "## Set OpenAI Key\n", 73 | "\n", 74 | " Get yours here: https://platform.openai.com/account/api-keys" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "metadata": { 81 | "dotnet_interactive": { 82 | "language": "pwsh" 83 | }, 84 | "polyglot_notebook": { 85 | "kernelName": "pwsh" 86 | } 87 | }, 88 | "outputs": [ 89 | { 90 | "name": "stdout", 91 | "output_type": "stream", 92 | "text": [ 93 | "OpenAIKey is already set\r\n" 94 | ] 95 | } 96 | ], 97 | "source": [ 98 | "if(!$env:OpenAIKey) {\n", 99 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 100 | "}\n", 101 | "else {\n", 102 | " \"OpenAIKey is already set\"\n", 103 | "}" 104 | ] 105 | }, 106 | { 107 | "attachments": {}, 108 | "cell_type": "markdown", 109 | "metadata": {}, 110 | "source": [ 111 | "## Define Prompt" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": 2, 117 | "metadata": { 118 | "dotnet_interactive": { 119 | "language": "pwsh" 120 | }, 121 | "polyglot_notebook": { 122 | "kernelName": "pwsh" 123 | } 124 | }, 125 | "outputs": [], 126 | "source": [ 127 | "$prompt = @'\n", 128 | "Create a list of 8 questions for my interview with a science fiction author:\n", 129 | "'@" 130 | ] 131 | }, 132 | { 133 | "attachments": {}, 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "## Ask GPT" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 3, 143 | "metadata": { 144 | "dotnet_interactive": { 145 | "language": "pwsh" 146 | }, 147 | "polyglot_notebook": { 148 | "kernelName": "pwsh" 149 | } 150 | }, 151 | "outputs": [ 152 | { 153 | "name": "stdout", 154 | "output_type": "stream", 155 | "text": [ 156 | "\n", 157 | "\n", 158 | "1. What inspired you to write science fiction?\n", 159 | "2. What themes do you explore in your writing?\n", 160 | "3. How do you come up with ideas for your stories?\n", 161 | "4. What do you think makes a great science fiction story?\n", 162 | "5. What do you think are the biggest challenges facing science fiction authors today?\n", 163 | "6. What advice would you give to aspiring science fiction authors?\n", 164 | "7. What do you think is the most important element of a successful science fiction novel?\n", 165 | "8. What do you think is the future of science fiction?\r\n" 166 | ] 167 | } 168 | ], 169 | "source": [ 170 | "gpt $prompt" 171 | ] 172 | } 173 | ], 174 | "metadata": { 175 | "kernelspec": { 176 | "display_name": ".NET (PowerShell)", 177 | "language": "PowerShell", 178 | "name": ".net-pwsh" 179 | }, 180 | "language_info": { 181 | "name": "polyglot-notebook" 182 | }, 183 | "polyglot_notebook": { 184 | "kernelInfo": { 185 | "defaultKernelName": "pwsh", 186 | "items": [ 187 | { 188 | "aliases": [], 189 | "languageName": "pwsh", 190 | "name": "pwsh" 191 | } 192 | ] 193 | } 194 | } 195 | }, 196 | "nbformat": 4, 197 | "nbformat_minor": 2 198 | } 199 | -------------------------------------------------------------------------------- /OpenAI-Samples/extract-contact-information.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Extract contact information\n", 9 | "\n", 10 | "Extract contact information from a block of text.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "Extract the name and mailing address from this email:\n", 28 | "\n", 29 | "Dear Kelly,\n", 30 | "\n", 31 | "It was great to talk to you at the seminar. I thought Jane's talk was quite good.\n", 32 | "\n", 33 | "Thank you for the book. Here's my address 2111 Ash Lane, Crestview CA 92002\n", 34 | "\n", 35 | "Best,\n", 36 | "\n", 37 | "Maya\n", 38 | "\n", 39 | "Name:\n", 40 | "```" 41 | ] 42 | }, 43 | { 44 | "attachments": {}, 45 | "cell_type": "markdown", 46 | "metadata": {}, 47 | "source": [ 48 | "## Install PowerShellAI" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 1, 54 | "metadata": { 55 | "dotnet_interactive": { 56 | "language": "pwsh" 57 | }, 58 | "polyglot_notebook": { 59 | "kernelName": "pwsh" 60 | } 61 | }, 62 | "outputs": [ 63 | { 64 | "name": "stdout", 65 | "output_type": "stream", 66 | "text": [ 67 | "PowerShellAI is already installed\r\n" 68 | ] 69 | } 70 | ], 71 | "source": [ 72 | "if(Get-Module -list PowerShellAI) {\n", 73 | " \"PowerShellAI is already installed\"\n", 74 | "} \n", 75 | "else {\n", 76 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 77 | "}" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "metadata": {}, 83 | "source": [ 84 | "## Set OpenAI Key\n", 85 | "\n", 86 | " Get yours here: https://platform.openai.com/account/api-keys" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": { 93 | "dotnet_interactive": { 94 | "language": "pwsh" 95 | }, 96 | "polyglot_notebook": { 97 | "kernelName": "pwsh" 98 | } 99 | }, 100 | "outputs": [ 101 | { 102 | "name": "stdout", 103 | "output_type": "stream", 104 | "text": [ 105 | "OpenAIKey is already set\r\n" 106 | ] 107 | } 108 | ], 109 | "source": [ 110 | "if(!$env:OpenAIKey) {\n", 111 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 112 | "}\n", 113 | "else {\n", 114 | " \"OpenAIKey is already set\"\n", 115 | "}" 116 | ] 117 | }, 118 | { 119 | "attachments": {}, 120 | "cell_type": "markdown", 121 | "metadata": {}, 122 | "source": [ 123 | "## Define Prompt" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 1, 129 | "metadata": { 130 | "dotnet_interactive": { 131 | "language": "pwsh" 132 | }, 133 | "polyglot_notebook": { 134 | "kernelName": "pwsh" 135 | } 136 | }, 137 | "outputs": [], 138 | "source": [ 139 | "$prompt = @'\n", 140 | "Extract the name and mailing address from this email:\n", 141 | "\n", 142 | "Dear Kelly,\n", 143 | "\n", 144 | "It was great to talk to you at the seminar. I thought Jane's talk was quite good.\n", 145 | "\n", 146 | "Thank you for the book. Here's my address 2111 Ash Lane, Crestview CA 92002\n", 147 | "\n", 148 | "Best,\n", 149 | "\n", 150 | "Maya\n", 151 | "\n", 152 | "Name: \n", 153 | "'@" 154 | ] 155 | }, 156 | { 157 | "attachments": {}, 158 | "cell_type": "markdown", 159 | "metadata": {}, 160 | "source": [ 161 | "## Ask GPT" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 2, 167 | "metadata": { 168 | "dotnet_interactive": { 169 | "language": "pwsh" 170 | }, 171 | "polyglot_notebook": { 172 | "kernelName": "pwsh" 173 | } 174 | }, 175 | "outputs": [ 176 | { 177 | "name": "stdout", 178 | "output_type": "stream", 179 | "text": [ 180 | " Maya\r\n", 181 | "Mailing Address: 2111 Ash Lane, Crestview CA 92002\r\n" 182 | ] 183 | } 184 | ], 185 | "source": [ 186 | "gpt $prompt -max_tokens 512" 187 | ] 188 | } 189 | ], 190 | "metadata": { 191 | "kernelspec": { 192 | "display_name": ".NET (PowerShell)", 193 | "language": "PowerShell", 194 | "name": ".net-pwsh" 195 | }, 196 | "language_info": { 197 | "name": "polyglot-notebook" 198 | }, 199 | "polyglot_notebook": { 200 | "kernelInfo": { 201 | "defaultKernelName": "pwsh", 202 | "items": [ 203 | { 204 | "aliases": [], 205 | "languageName": "pwsh", 206 | "name": "pwsh" 207 | } 208 | ] 209 | } 210 | } 211 | }, 212 | "nbformat": 4, 213 | "nbformat_minor": 2 214 | } 215 | -------------------------------------------------------------------------------- /OpenAI-Samples/calculate-time-complexity.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Calculate Time Complexity\n", 9 | "\n", 10 | "Find the time complexity of a function.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "function Foo($n, $k)\n", 28 | "{\n", 29 | " $accum = 0\n", 30 | " foreach($i in 1..$n)\n", 31 | " {\n", 32 | " foreach($l in 1..$k)\n", 33 | " {\n", 34 | " $accum += $i;\n", 35 | " }\n", 36 | " }\n", 37 | " return $accum;\n", 38 | "}\n", 39 | "\n", 40 | "# The time complexity of this function is\n", 41 | "```" 42 | ] 43 | }, 44 | { 45 | "attachments": {}, 46 | "cell_type": "markdown", 47 | "metadata": {}, 48 | "source": [ 49 | "## Install PowerShellAI" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 2, 55 | "metadata": { 56 | "dotnet_interactive": { 57 | "language": "pwsh" 58 | }, 59 | "polyglot_notebook": { 60 | "kernelName": "pwsh" 61 | } 62 | }, 63 | "outputs": [ 64 | { 65 | "name": "stdout", 66 | "output_type": "stream", 67 | "text": [ 68 | "PowerShellAI is already installed\r\n" 69 | ] 70 | } 71 | ], 72 | "source": [ 73 | "if(Get-Module -list PowerShellAI) {\n", 74 | " \"PowerShellAI is already installed\"\n", 75 | "} \n", 76 | "else {\n", 77 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 78 | "}" 79 | ] 80 | }, 81 | { 82 | "cell_type": "markdown", 83 | "metadata": {}, 84 | "source": [ 85 | "## Set OpenAI Key\n", 86 | "\n", 87 | " Get yours here: https://platform.openai.com/account/api-keys" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 3, 93 | "metadata": { 94 | "dotnet_interactive": { 95 | "language": "pwsh" 96 | }, 97 | "polyglot_notebook": { 98 | "kernelName": "pwsh" 99 | } 100 | }, 101 | "outputs": [ 102 | { 103 | "name": "stdout", 104 | "output_type": "stream", 105 | "text": [ 106 | "OpenAIKey is already set\r\n" 107 | ] 108 | } 109 | ], 110 | "source": [ 111 | "if(!$env:OpenAIKey) {\n", 112 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 113 | "}\n", 114 | "else {\n", 115 | " \"OpenAIKey is already set\"\n", 116 | "}" 117 | ] 118 | }, 119 | { 120 | "attachments": {}, 121 | "cell_type": "markdown", 122 | "metadata": {}, 123 | "source": [ 124 | "## Define Prompt" 125 | ] 126 | }, 127 | { 128 | "cell_type": "code", 129 | "execution_count": 4, 130 | "metadata": { 131 | "dotnet_interactive": { 132 | "language": "pwsh" 133 | }, 134 | "polyglot_notebook": { 135 | "kernelName": "pwsh" 136 | } 137 | }, 138 | "outputs": [], 139 | "source": [ 140 | "$prompt = @'\n", 141 | "function Foo($n, $k)\n", 142 | "{\n", 143 | " $accum = 0\n", 144 | " foreach($i in 1..$n)\n", 145 | " {\n", 146 | " foreach($l in 1..$k)\n", 147 | " {\n", 148 | " $accum += $i;\n", 149 | " }\n", 150 | " }\n", 151 | " return $accum;\n", 152 | "}\n", 153 | "\n", 154 | "# The time complexity of this function is\n", 155 | "'@" 156 | ] 157 | }, 158 | { 159 | "attachments": {}, 160 | "cell_type": "markdown", 161 | "metadata": {}, 162 | "source": [ 163 | "## Ask GPT" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 5, 169 | "metadata": { 170 | "dotnet_interactive": { 171 | "language": "pwsh" 172 | }, 173 | "polyglot_notebook": { 174 | "kernelName": "pwsh" 175 | } 176 | }, 177 | "outputs": [ 178 | { 179 | "name": "stdout", 180 | "output_type": "stream", 181 | "text": [ 182 | " O(n*k). This is because the function has two nested for loops, and the number of iterations of the inner loop is dependent on the value of the outer loop. Therefore, the total number of iterations is n*k.\r\n" 183 | ] 184 | } 185 | ], 186 | "source": [ 187 | "gpt $prompt" 188 | ] 189 | } 190 | ], 191 | "metadata": { 192 | "kernelspec": { 193 | "display_name": ".NET (PowerShell)", 194 | "language": "PowerShell", 195 | "name": ".net-pwsh" 196 | }, 197 | "language_info": { 198 | "name": "polyglot-notebook" 199 | }, 200 | "polyglot_notebook": { 201 | "kernelInfo": { 202 | "defaultKernelName": "pwsh", 203 | "items": [ 204 | { 205 | "aliases": [], 206 | "languageName": "pwsh", 207 | "name": "pwsh" 208 | } 209 | ] 210 | } 211 | } 212 | }, 213 | "nbformat": 4, 214 | "nbformat_minor": 2 215 | } 216 | -------------------------------------------------------------------------------- /OpenAI-Samples/powershell-to-natural-language.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Create interview questions\n", 9 | "\n", 10 | "Create interview questions.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "# PowerShell\n", 28 | "function Remove-Prefix {\n", 29 | " param(\n", 30 | " [string]$str,\n", 31 | " [string]$prefix = \" \"\n", 32 | " )\n", 33 | " if ($str.StartsWith($prefix)) {\n", 34 | " return $str.Substring($prefix.Length)\n", 35 | " }\n", 36 | " return $str\n", 37 | "}\n", 38 | "\n", 39 | "# Explain what this code does\n", 40 | "```" 41 | ] 42 | }, 43 | { 44 | "attachments": {}, 45 | "cell_type": "markdown", 46 | "metadata": {}, 47 | "source": [ 48 | "## Install PowerShellAI" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 1, 54 | "metadata": { 55 | "dotnet_interactive": { 56 | "language": "pwsh" 57 | }, 58 | "polyglot_notebook": { 59 | "kernelName": "pwsh" 60 | } 61 | }, 62 | "outputs": [ 63 | { 64 | "name": "stdout", 65 | "output_type": "stream", 66 | "text": [ 67 | "PowerShellAI is already installed\r\n" 68 | ] 69 | } 70 | ], 71 | "source": [ 72 | "if(Get-Module -list PowerShellAI) {\n", 73 | " \"PowerShellAI is already installed\"\n", 74 | "} \n", 75 | "else {\n", 76 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 77 | "}" 78 | ] 79 | }, 80 | { 81 | "cell_type": "markdown", 82 | "metadata": {}, 83 | "source": [ 84 | "## Set OpenAI Key\n", 85 | "\n", 86 | " Get yours here: https://platform.openai.com/account/api-keys" 87 | ] 88 | }, 89 | { 90 | "cell_type": "code", 91 | "execution_count": null, 92 | "metadata": { 93 | "dotnet_interactive": { 94 | "language": "pwsh" 95 | }, 96 | "polyglot_notebook": { 97 | "kernelName": "pwsh" 98 | } 99 | }, 100 | "outputs": [ 101 | { 102 | "name": "stdout", 103 | "output_type": "stream", 104 | "text": [ 105 | "OpenAIKey is already set\r\n" 106 | ] 107 | } 108 | ], 109 | "source": [ 110 | "if(!$env:OpenAIKey) {\n", 111 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 112 | "}\n", 113 | "else {\n", 114 | " \"OpenAIKey is already set\"\n", 115 | "}" 116 | ] 117 | }, 118 | { 119 | "attachments": {}, 120 | "cell_type": "markdown", 121 | "metadata": {}, 122 | "source": [ 123 | "## Define Prompt" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 1, 129 | "metadata": { 130 | "dotnet_interactive": { 131 | "language": "pwsh" 132 | }, 133 | "polyglot_notebook": { 134 | "kernelName": "pwsh" 135 | } 136 | }, 137 | "outputs": [], 138 | "source": [ 139 | "$prompt = @'\n", 140 | "# PowerShell\n", 141 | "function Remove-Prefix {\n", 142 | " param(\n", 143 | " [string]$str,\n", 144 | " [string]$prefix = \" \"\n", 145 | " )\n", 146 | " if ($str.StartsWith($prefix)) {\n", 147 | " return $str.Substring($prefix.Length)\n", 148 | " }\n", 149 | " return $str\n", 150 | "}\n", 151 | "\n", 152 | "# Explain what this code does\n", 153 | "'@" 154 | ] 155 | }, 156 | { 157 | "attachments": {}, 158 | "cell_type": "markdown", 159 | "metadata": {}, 160 | "source": [ 161 | "## Ask GPT" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": 2, 167 | "metadata": { 168 | "dotnet_interactive": { 169 | "language": "pwsh" 170 | }, 171 | "polyglot_notebook": { 172 | "kernelName": "pwsh" 173 | } 174 | }, 175 | "outputs": [ 176 | { 177 | "name": "stdout", 178 | "output_type": "stream", 179 | "text": [ 180 | "\r\n", 181 | "\r\n", 182 | "This code is a function called Remove-Prefix that takes two parameters, a string and a prefix. The function checks if the string starts with the prefix and if it does, it returns the string with the prefix removed. If the string does not start with the prefix, the function returns the string as is.\r\n" 183 | ] 184 | } 185 | ], 186 | "source": [ 187 | "gpt $prompt" 188 | ] 189 | } 190 | ], 191 | "metadata": { 192 | "kernelspec": { 193 | "display_name": ".NET (PowerShell)", 194 | "language": "PowerShell", 195 | "name": ".net-pwsh" 196 | }, 197 | "language_info": { 198 | "name": "polyglot-notebook" 199 | }, 200 | "polyglot_notebook": { 201 | "kernelInfo": { 202 | "defaultKernelName": "pwsh", 203 | "items": [ 204 | { 205 | "aliases": [], 206 | "languageName": "pwsh", 207 | "name": "pwsh" 208 | } 209 | ] 210 | } 211 | } 212 | }, 213 | "nbformat": 4, 214 | "nbformat_minor": 2 215 | } 216 | -------------------------------------------------------------------------------- /Azure-OpenAI-Samples/airport-code-extractor.azure.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Airport code extractor\n", 9 | "\n", 10 | "A simple prompt for extracting airport codes from text.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "Extract the airport codes from this text:\n", 28 | "\n", 29 | "Text: \"I want to fly from Los Angeles to Miami.\"\n", 30 | "Airport codes: LAX, MIA\n", 31 | "\n", 32 | "Text: \"I want to fly from Orlando to Boston\"\n", 33 | "Airport codes:\n", 34 | "```" 35 | ] 36 | }, 37 | { 38 | "attachments": {}, 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "## Install PowerShellAI" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 6, 48 | "metadata": { 49 | "dotnet_interactive": { 50 | "language": "pwsh" 51 | }, 52 | "polyglot_notebook": { 53 | "kernelName": "pwsh" 54 | } 55 | }, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "PowerShellAI is already installed\r\n" 62 | ] 63 | } 64 | ], 65 | "source": [ 66 | "if(Get-Module -list PowerShellAI) {\n", 67 | " \"PowerShellAI is already installed\"\n", 68 | "} \n", 69 | "else {\n", 70 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 71 | "}" 72 | ] 73 | }, 74 | { 75 | "attachments": {}, 76 | "cell_type": "markdown", 77 | "metadata": {}, 78 | "source": [ 79 | "## Config Azure OpenAI client" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 7, 85 | "metadata": { 86 | "dotnet_interactive": { 87 | "language": "pwsh" 88 | }, 89 | "polyglot_notebook": { 90 | "kernelName": "pwsh" 91 | } 92 | }, 93 | "outputs": [], 94 | "source": [ 95 | "$params = @{\n", 96 | " Endpoint = \"https://dcfopenai.openai.azure.com\"\n", 97 | " DeploymentName = \"dcfopenai\"\n", 98 | " ApiVersion = \"2023-03-15-preview\"\n", 99 | " ApiKey = \"eceexxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n", 100 | "}\n", 101 | "\n", 102 | "Set-AzureOpenAI @params" 103 | ] 104 | }, 105 | { 106 | "attachments": {}, 107 | "cell_type": "markdown", 108 | "metadata": {}, 109 | "source": [ 110 | "## Define prompt" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 8, 116 | "metadata": { 117 | "dotnet_interactive": { 118 | "language": "pwsh" 119 | }, 120 | "polyglot_notebook": { 121 | "kernelName": "pwsh" 122 | } 123 | }, 124 | "outputs": [], 125 | "source": [ 126 | "$prompt = @\"\n", 127 | "Extract the airport codes from this text:\n", 128 | "\n", 129 | "Text: \"I want to fly from Los Angeles to Miami.\"\n", 130 | "Airport codes: LAX, MIA\n", 131 | "\n", 132 | "Text: \"I want to fly from Orlando to Boston\"\n", 133 | "Airport codes:\n", 134 | "\"@" 135 | ] 136 | }, 137 | { 138 | "attachments": {}, 139 | "cell_type": "markdown", 140 | "metadata": {}, 141 | "source": [ 142 | "## Generate completions" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": 9, 148 | "metadata": { 149 | "dotnet_interactive": { 150 | "language": "pwsh" 151 | }, 152 | "polyglot_notebook": { 153 | "kernelName": "pwsh" 154 | } 155 | }, 156 | "outputs": [ 157 | { 158 | "name": "stdout", 159 | "output_type": "stream", 160 | "text": [ 161 | "MCO, BOS\r\n" 162 | ] 163 | } 164 | ], 165 | "source": [ 166 | "chat $prompt " 167 | ] 168 | }, 169 | { 170 | "attachments": {}, 171 | "cell_type": "markdown", 172 | "metadata": {}, 173 | "source": [ 174 | "## Stop The Chat\n", 175 | "\n", 176 | "- `chat` is conversational\n", 177 | "- It maintains the coversation\n", 178 | "- You need to close the conversation with `stop-chat` so the conversation is reset\n" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 10, 184 | "metadata": { 185 | "dotnet_interactive": { 186 | "language": "pwsh" 187 | }, 188 | "polyglot_notebook": { 189 | "kernelName": "pwsh" 190 | } 191 | }, 192 | "outputs": [], 193 | "source": [ 194 | "Stop-Chat" 195 | ] 196 | } 197 | ], 198 | "metadata": { 199 | "kernelspec": { 200 | "display_name": ".NET (PowerShell)", 201 | "language": "PowerShell", 202 | "name": ".net-pwsh" 203 | }, 204 | "language_info": { 205 | "name": "polyglot-notebook" 206 | }, 207 | "polyglot_notebook": { 208 | "kernelInfo": { 209 | "defaultKernelName": "pwsh", 210 | "items": [ 211 | { 212 | "aliases": [], 213 | "languageName": "pwsh", 214 | "name": "pwsh" 215 | } 216 | ] 217 | } 218 | } 219 | }, 220 | "nbformat": 4, 221 | "nbformat_minor": 2 222 | } 223 | -------------------------------------------------------------------------------- /OpenAI-Samples/extract-keywords.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Extract Keywords\n", 9 | "\n", 10 | "Extract keywords from a block of text. At a lower temperature it picks keywords from the text. At a higher temperature it will generate related keywords which can be helpful for creating search indexes.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "Extract keywords from this text:\n", 28 | "\n", 29 | "Black-on-black ware is a 20th- and 21st-century pottery tradition developed by the Puebloan Native American ceramic artists in Northern New Mexico. Traditional reduction-fired blackware has been made for centuries by pueblo artists. Black-on-black ware of the past century is produced with a smooth surface, with the designs applied through selective burnishing or the application of refractory slip. Another style involves carving or incising designs and selectively polishing the raised areas. For generations several families from Kha'po Owingeh and P'ohwhóge Owingeh pueblos have been making black-on-black ware with the techniques passed down from matriarch potters. Artists from other pueblos have also produced black-on-black ware. Several contemporary artists have created works honoring the pottery of their ancestors.\n", 30 | "```" 31 | ] 32 | }, 33 | { 34 | "attachments": {}, 35 | "cell_type": "markdown", 36 | "metadata": {}, 37 | "source": [ 38 | "## Install PowerShellAI" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 1, 44 | "metadata": { 45 | "dotnet_interactive": { 46 | "language": "pwsh" 47 | }, 48 | "polyglot_notebook": { 49 | "kernelName": "pwsh" 50 | } 51 | }, 52 | "outputs": [ 53 | { 54 | "name": "stdout", 55 | "output_type": "stream", 56 | "text": [ 57 | "PowerShellAI is already installed\r\n" 58 | ] 59 | } 60 | ], 61 | "source": [ 62 | "if(Get-Module -list PowerShellAI) {\n", 63 | " \"PowerShellAI is already installed\"\n", 64 | "} \n", 65 | "else {\n", 66 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 67 | "}" 68 | ] 69 | }, 70 | { 71 | "cell_type": "markdown", 72 | "metadata": {}, 73 | "source": [ 74 | "## Set OpenAI Key\n", 75 | "\n", 76 | " Get yours here: https://platform.openai.com/account/api-keys" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": null, 82 | "metadata": { 83 | "dotnet_interactive": { 84 | "language": "pwsh" 85 | }, 86 | "polyglot_notebook": { 87 | "kernelName": "pwsh" 88 | } 89 | }, 90 | "outputs": [ 91 | { 92 | "name": "stdout", 93 | "output_type": "stream", 94 | "text": [ 95 | "OpenAIKey is already set\r\n" 96 | ] 97 | } 98 | ], 99 | "source": [ 100 | "if(!$env:OpenAIKey) {\n", 101 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 102 | "}\n", 103 | "else {\n", 104 | " \"OpenAIKey is already set\"\n", 105 | "}" 106 | ] 107 | }, 108 | { 109 | "attachments": {}, 110 | "cell_type": "markdown", 111 | "metadata": {}, 112 | "source": [ 113 | "## Define Prompt" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": 1, 119 | "metadata": { 120 | "dotnet_interactive": { 121 | "language": "pwsh" 122 | }, 123 | "polyglot_notebook": { 124 | "kernelName": "pwsh" 125 | } 126 | }, 127 | "outputs": [], 128 | "source": [ 129 | "$prompt = @'\n", 130 | "Extract keywords from this text:\n", 131 | "\n", 132 | "Black-on-black ware is a 20th- and 21st-century pottery tradition developed by the Puebloan Native American ceramic artists in Northern New Mexico. Traditional reduction-fired blackware has been made for centuries by pueblo artists. Black-on-black ware of the past century is produced with a smooth surface, with the designs applied through selective burnishing or the application of refractory slip. Another style involves carving or incising designs and selectively polishing the raised areas. For generations several families from Kha'po Owingeh and P'ohwhóge Owingeh pueblos have been making black-on-black ware with the techniques passed down from matriarch potters. Artists from other pueblos have also produced black-on-black ware. Several contemporary artists have created works honoring the pottery of their ancestors.\n", 133 | "'@" 134 | ] 135 | }, 136 | { 137 | "attachments": {}, 138 | "cell_type": "markdown", 139 | "metadata": {}, 140 | "source": [ 141 | "## Ask GPT" 142 | ] 143 | }, 144 | { 145 | "cell_type": "code", 146 | "execution_count": 2, 147 | "metadata": { 148 | "dotnet_interactive": { 149 | "language": "pwsh" 150 | }, 151 | "polyglot_notebook": { 152 | "kernelName": "pwsh" 153 | } 154 | }, 155 | "outputs": [ 156 | { 157 | "name": "stdout", 158 | "output_type": "stream", 159 | "text": [ 160 | "\n", 161 | "\n", 162 | "-Black-on-black ware \n", 163 | "-Puebloan Native American \n", 164 | "-Ceramic artists \n", 165 | "-Northern New Mexico \n", 166 | "-Reduction-fired blackware \n", 167 | "-Smooth surface \n", 168 | "-Burnishing \n", 169 | "-Refractory slip \n", 170 | "-Carving \n", 171 | "-Incising \n", 172 | "-Polishing \n", 173 | "-Kha'po Owingeh \n", 174 | "-P'ohwhóge Owingeh \n", 175 | "-Matriarch potters \n", 176 | "-Other pueblos \n", 177 | "-Contemporary artists \n", 178 | "-Ancestors\r\n" 179 | ] 180 | } 181 | ], 182 | "source": [ 183 | "gpt $prompt -max_tokens 512" 184 | ] 185 | } 186 | ], 187 | "metadata": { 188 | "kernelspec": { 189 | "display_name": ".NET (PowerShell)", 190 | "language": "PowerShell", 191 | "name": ".net-pwsh" 192 | }, 193 | "language_info": { 194 | "name": "polyglot-notebook" 195 | }, 196 | "polyglot_notebook": { 197 | "kernelInfo": { 198 | "defaultKernelName": "pwsh", 199 | "items": [ 200 | { 201 | "aliases": [], 202 | "languageName": "pwsh", 203 | "name": "pwsh" 204 | } 205 | ] 206 | } 207 | } 208 | }, 209 | "nbformat": 4, 210 | "nbformat_minor": 2 211 | } 212 | -------------------------------------------------------------------------------- /OpenAI-Samples/explain-code.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Explain code\n", 9 | "\n", 10 | "Explain a complicated piece of code.\n", 11 | "\n", 12 | "## Settings\n", 13 | "\n", 14 | "| Setting | Value |\n", 15 | "| --- | --- |\n", 16 | "| Model | text-davinci-003 |\n", 17 | "| Max tokens | 256 |\n", 18 | "| Temperature | 0 | \n", 19 | "| Top p | 1 | \n", 20 | "| Frequency penalty | 0.0 |\n", 21 | "| Presence penalty | 0.0 |\n", 22 | "| Stop sequence | |\n", 23 | "\n", 24 | "## Prompt\n", 25 | "\n", 26 | "```text\n", 27 | "class MathUtils {\n", 28 | " static [double] CosineSimilarity([double[]]$vectorA, [double[]]$vectorB) {\n", 29 | " $dotProduct = 0.0\n", 30 | " $magnitudeA = 0.0\n", 31 | " $magnitudeB = 0.0\n", 32 | " $cosineSimilarity = 0.0\n", 33 | "\n", 34 | " for ($i = 0; $i -lt $vectorA.Length; $i++) {\n", 35 | " $dotProduct += $vectorA[$i] * $vectorB[$i]\n", 36 | " $magnitudeA += [Math]::Pow($vectorA[$i], 2)\n", 37 | " $magnitudeB += [Math]::Pow($vectorB[$i], 2)\n", 38 | " }\n", 39 | "\n", 40 | " $magnitudeA = [Math]::Sqrt($magnitudeA)\n", 41 | " $magnitudeB = [Math]::Sqrt($magnitudeB)\n", 42 | "\n", 43 | " if ($magnitudeA -ne 0 -and $magnitudeB -ne 0) {\n", 44 | " $cosineSimilarity = $dotProduct / ($magnitudeA * $magnitudeB)\n", 45 | " }\n", 46 | " else {\n", 47 | " return 0.0\n", 48 | " }\n", 49 | "\n", 50 | " return $cosineSimilarity\n", 51 | " }\n", 52 | "}\n", 53 | "\n", 54 | "Here's what the above class is doing, explained in a concise way:\n", 55 | "\n", 56 | "1. \n", 57 | "```" 58 | ] 59 | }, 60 | { 61 | "attachments": {}, 62 | "cell_type": "markdown", 63 | "metadata": {}, 64 | "source": [ 65 | "## Install PowerShellAI" 66 | ] 67 | }, 68 | { 69 | "cell_type": "code", 70 | "execution_count": 1, 71 | "metadata": { 72 | "dotnet_interactive": { 73 | "language": "pwsh" 74 | }, 75 | "polyglot_notebook": { 76 | "kernelName": "pwsh" 77 | } 78 | }, 79 | "outputs": [ 80 | { 81 | "name": "stdout", 82 | "output_type": "stream", 83 | "text": [ 84 | "PowerShellAI is already installed\r\n" 85 | ] 86 | } 87 | ], 88 | "source": [ 89 | "if(Get-Module -list PowerShellAI) {\n", 90 | " \"PowerShellAI is already installed\"\n", 91 | "} \n", 92 | "else {\n", 93 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 94 | "}" 95 | ] 96 | }, 97 | { 98 | "cell_type": "markdown", 99 | "metadata": {}, 100 | "source": [ 101 | "## Set OpenAI Key\n", 102 | "\n", 103 | " Get yours here: https://platform.openai.com/account/api-keys" 104 | ] 105 | }, 106 | { 107 | "cell_type": "code", 108 | "execution_count": null, 109 | "metadata": { 110 | "dotnet_interactive": { 111 | "language": "pwsh" 112 | }, 113 | "polyglot_notebook": { 114 | "kernelName": "pwsh" 115 | } 116 | }, 117 | "outputs": [ 118 | { 119 | "name": "stdout", 120 | "output_type": "stream", 121 | "text": [ 122 | "OpenAIKey is already set\r\n" 123 | ] 124 | } 125 | ], 126 | "source": [ 127 | "if(!$env:OpenAIKey) {\n", 128 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 129 | "}\n", 130 | "else {\n", 131 | " \"OpenAIKey is already set\"\n", 132 | "}" 133 | ] 134 | }, 135 | { 136 | "attachments": {}, 137 | "cell_type": "markdown", 138 | "metadata": {}, 139 | "source": [ 140 | "## Define Prompt" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": 2, 146 | "metadata": { 147 | "dotnet_interactive": { 148 | "language": "pwsh" 149 | }, 150 | "polyglot_notebook": { 151 | "kernelName": "pwsh" 152 | } 153 | }, 154 | "outputs": [], 155 | "source": [ 156 | "$prompt = @'\n", 157 | "class MathUtils {\n", 158 | " static [double] CosineSimilarity([double[]]$vectorA, [double[]]$vectorB) {\n", 159 | " $dotProduct = 0.0\n", 160 | " $magnitudeA = 0.0\n", 161 | " $magnitudeB = 0.0\n", 162 | " $cosineSimilarity = 0.0\n", 163 | "\n", 164 | " for ($i = 0; $i -lt $vectorA.Length; $i++) {\n", 165 | " $dotProduct += $vectorA[$i] * $vectorB[$i]\n", 166 | " $magnitudeA += [Math]::Pow($vectorA[$i], 2)\n", 167 | " $magnitudeB += [Math]::Pow($vectorB[$i], 2)\n", 168 | " }\n", 169 | "\n", 170 | " $magnitudeA = [Math]::Sqrt($magnitudeA)\n", 171 | " $magnitudeB = [Math]::Sqrt($magnitudeB)\n", 172 | "\n", 173 | " if ($magnitudeA -ne 0 -and $magnitudeB -ne 0) {\n", 174 | " $cosineSimilarity = $dotProduct / ($magnitudeA * $magnitudeB)\n", 175 | " }\n", 176 | " else {\n", 177 | " return 0.0\n", 178 | " }\n", 179 | "\n", 180 | " return $cosineSimilarity\n", 181 | " }\n", 182 | "}\n", 183 | "\n", 184 | "Here's what the above class is doing, explained in a concise way:\n", 185 | "\n", 186 | "1. \n", 187 | "'@" 188 | ] 189 | }, 190 | { 191 | "attachments": {}, 192 | "cell_type": "markdown", 193 | "metadata": {}, 194 | "source": [ 195 | "## Ask GPT" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": 4, 201 | "metadata": { 202 | "dotnet_interactive": { 203 | "language": "pwsh" 204 | }, 205 | "polyglot_notebook": { 206 | "kernelName": "pwsh" 207 | } 208 | }, 209 | "outputs": [ 210 | { 211 | "name": "stdout", 212 | "output_type": "stream", 213 | "text": [ 214 | " The MathUtils class contains a static method called CosineSimilarity which takes two double arrays as parameters.\r\n", 215 | "2. The method calculates the dot product of the two arrays, the magnitude of each array, and the cosine similarity between them. \r\n", 216 | "3. The dot product is calculated by looping through each array and multiplying the corresponding elements. \r\n", 217 | "4. The magnitude of each array is calculated by taking the square root of the sum of the squares of each element in the array. \r\n", 218 | "5. The cosine similarity is calculated by dividing the dot product by the product of the magnitudes of the two arrays. \r\n", 219 | "6. If either of the magnitudes is 0, the method returns 0.0. Otherwise, it returns the cosine similarity.\r\n" 220 | ] 221 | } 222 | ], 223 | "source": [ 224 | "gpt $prompt -max_tokens 512" 225 | ] 226 | } 227 | ], 228 | "metadata": { 229 | "kernelspec": { 230 | "display_name": ".NET (PowerShell)", 231 | "language": "PowerShell", 232 | "name": ".net-pwsh" 233 | }, 234 | "language_info": { 235 | "name": "polyglot-notebook" 236 | }, 237 | "polyglot_notebook": { 238 | "kernelInfo": { 239 | "defaultKernelName": "pwsh", 240 | "items": [ 241 | { 242 | "aliases": [], 243 | "languageName": "pwsh", 244 | "name": "pwsh" 245 | } 246 | ] 247 | } 248 | } 249 | }, 250 | "nbformat": 4, 251 | "nbformat_minor": 2 252 | } 253 | -------------------------------------------------------------------------------- /OpenAI-Samples/chatgpt-hiking-recommendations.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# ChatGPT Hiking Recommendations Assistant\n", 9 | "\n", 10 | "Multi-turn conversation assistant to get local hiking recommendations. Uses ChatGPT (GPT3.5 Turbo) model.\n", 11 | "\n", 12 | "\n", 13 | "## Settings\n", 14 | "\n", 15 | "| Setting | Value |\n", 16 | "| --- | --- |\n", 17 | "| Model | text-davinci-003 |\n", 18 | "| Max tokens | 256 |\n", 19 | "| Temperature | 0 | \n", 20 | "| Top p | 1 | \n", 21 | "| Frequency penalty | 0.0 |\n", 22 | "| Presence penalty | 0.0 |\n", 23 | "| Stop sequence | |\n", 24 | "\n", 25 | "## Prompt\n", 26 | "\n", 27 | "```text\n", 28 | "You are a hiking enthusiast who helps people discover fun hikes in their area. You are upbeat and friendly. You introduce yourself when first saying hello. When helping people out, you always ask them for this information to inform the hiking recommendation you provide:\n", 29 | "\n", 30 | "1. Where they are located\n", 31 | "2. What hiking intensity they are looking for\n", 32 | "\n", 33 | "You will then provide three suggestions for nearby hikes that vary in length after you get that information. You will also share an interesting fact about the local nature on the hikes when making a recommendation.\n", 34 | "```" 35 | ] 36 | }, 37 | { 38 | "attachments": {}, 39 | "cell_type": "markdown", 40 | "metadata": {}, 41 | "source": [ 42 | "## Install PowerShellAI" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": 4, 48 | "metadata": { 49 | "dotnet_interactive": { 50 | "language": "pwsh" 51 | }, 52 | "polyglot_notebook": { 53 | "kernelName": "pwsh" 54 | } 55 | }, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "PowerShellAI is already installed\r\n" 62 | ] 63 | } 64 | ], 65 | "source": [ 66 | "if(Get-Module -list PowerShellAI) {\n", 67 | " \"PowerShellAI is already installed\"\n", 68 | "} \n", 69 | "else {\n", 70 | " Install-Module -Name PowerShellAI -Scope AllUsers -Force\n", 71 | "}" 72 | ] 73 | }, 74 | { 75 | "cell_type": "markdown", 76 | "metadata": {}, 77 | "source": [ 78 | "## Set OpenAI Key\n", 79 | "\n", 80 | " Get yours here: https://platform.openai.com/account/api-keys" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 5, 86 | "metadata": { 87 | "dotnet_interactive": { 88 | "language": "pwsh" 89 | }, 90 | "polyglot_notebook": { 91 | "kernelName": "pwsh" 92 | } 93 | }, 94 | "outputs": [ 95 | { 96 | "name": "stdout", 97 | "output_type": "stream", 98 | "text": [ 99 | "OpenAIKey is already set\r\n" 100 | ] 101 | } 102 | ], 103 | "source": [ 104 | "if(!$env:OpenAIKey) {\n", 105 | " $env:OpenAIKey='sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\n", 106 | "}\n", 107 | "else {\n", 108 | " \"OpenAIKey is already set\"\n", 109 | "}" 110 | ] 111 | }, 112 | { 113 | "attachments": {}, 114 | "cell_type": "markdown", 115 | "metadata": {}, 116 | "source": [ 117 | "## Define System Message" 118 | ] 119 | }, 120 | { 121 | "cell_type": "code", 122 | "execution_count": 1, 123 | "metadata": { 124 | "dotnet_interactive": { 125 | "language": "pwsh" 126 | }, 127 | "polyglot_notebook": { 128 | "kernelName": "pwsh" 129 | } 130 | }, 131 | "outputs": [], 132 | "source": [ 133 | "$system = @'\n", 134 | "You are a hiking enthusiast who helps people discover fun hikes in their area. You are upbeat and friendly. You introduce yourself when first saying hello. When helping people out, you always ask them for this information to inform the hiking recommendation you provide:\n", 135 | "\n", 136 | "1. Where they are located\n", 137 | "2. What hiking intensity they are looking for\n", 138 | "\n", 139 | "You will then provide three suggestions for nearby hikes that vary in length after you get that information. You will also share an interesting fact about the local nature on the hikes when making a recommendation.\n", 140 | "'@" 141 | ] 142 | }, 143 | { 144 | "attachments": {}, 145 | "cell_type": "markdown", 146 | "metadata": {}, 147 | "source": [ 148 | "## Add initial system message" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": 2, 154 | "metadata": { 155 | "dotnet_interactive": { 156 | "language": "pwsh" 157 | }, 158 | "polyglot_notebook": { 159 | "kernelName": "pwsh" 160 | } 161 | }, 162 | "outputs": [ 163 | { 164 | "name": "stdout", 165 | "output_type": "stream", 166 | "text": [ 167 | "Hello! I'm your friendly hiking enthusiast, here to help you discover fun hikes in your area. To get started, please let me know:\n", 168 | "\n", 169 | "1. Where you are located\n", 170 | "2. What hiking intensity you are looking for\n", 171 | "\n", 172 | "Once I have this information, I'll provide you with three suggestions for nearby hikes that vary in length, along with an interesting fact about the local nature on each hike. Happy hiking!\r\n" 173 | ] 174 | } 175 | ], 176 | "source": [ 177 | "New-Chat $system" 178 | ] 179 | }, 180 | { 181 | "attachments": {}, 182 | "cell_type": "markdown", 183 | "metadata": {}, 184 | "source": [ 185 | "## Start Chat from User" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": 3, 191 | "metadata": { 192 | "dotnet_interactive": { 193 | "language": "pwsh" 194 | }, 195 | "polyglot_notebook": { 196 | "kernelName": "pwsh" 197 | } 198 | }, 199 | "outputs": [ 200 | { 201 | "name": "stdout", 202 | "output_type": "stream", 203 | "text": [ 204 | "Hello! I'm your friendly hiking enthusiast, here to help you discover fun hikes in your area. To get started, please let me know:\n", 205 | "\n", 206 | "1. Where you are located\n", 207 | "2. What hiking intensity you are looking for\n", 208 | "\n", 209 | "Once I have this information, I'll provide you with three suggestions for nearby hikes that vary in length, along with an interesting fact about the local nature on each hike. Happy hiking!\r\n" 210 | ] 211 | } 212 | ], 213 | "source": [ 214 | "chat 'hi'" 215 | ] 216 | }, 217 | { 218 | "attachments": {}, 219 | "cell_type": "markdown", 220 | "metadata": {}, 221 | "source": [ 222 | "## Continue the conversation" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 6, 228 | "metadata": { 229 | "dotnet_interactive": { 230 | "language": "pwsh" 231 | }, 232 | "polyglot_notebook": { 233 | "kernelName": "pwsh" 234 | } 235 | }, 236 | "outputs": [ 237 | { 238 | "name": "stdout", 239 | "output_type": "stream", 240 | "text": [ 241 | "Hello! I'd be happy to help you find some great hikes in the Hudson Valley area. To provide the best recommendations, please let me know what hiking intensity you are looking for. Once I have this information, I'll provide you with three suggestions for nearby hikes that vary in length, along with an interesting fact about the local nature on each hike. Happy hiking!\r\n" 242 | ] 243 | } 244 | ], 245 | "source": [ 246 | "chat 'Give me a list of the top 3 hikes in the Hudson Valley area'" 247 | ] 248 | }, 249 | { 250 | "cell_type": "code", 251 | "execution_count": 7, 252 | "metadata": { 253 | "dotnet_interactive": { 254 | "language": "pwsh" 255 | }, 256 | "polyglot_notebook": { 257 | "kernelName": "pwsh" 258 | } 259 | }, 260 | "outputs": [ 261 | { 262 | "name": "stdout", 263 | "output_type": "stream", 264 | "text": [ 265 | "Great! Thanks for providing your location and interest in various hiking intensities. Here are three hikes near Beacon, NY, with varying levels of difficulty:\n", 266 | "\n", 267 | "1. Easy: Madam Brett Park\n", 268 | "- Length: 2.5 miles round trip\n", 269 | "- Interesting fact: This park features a beautiful waterfall called Tioronda Falls, which is a great spot for photography and relaxation.\n", 270 | "\n", 271 | "2. Moderate: Breakneck Ridge Trail\n", 272 | "- Length: 5.5 miles round trip\n", 273 | "- Interesting fact: Breakneck Ridge is one of the most popular day hikes in the Hudson Valley, offering stunning views of the Hudson River and surrounding mountains. The trail includes some rock scrambling, making it a fun and challenging experience.\n", 274 | "\n", 275 | "3. Difficult: Mount Beacon Fire Tower Trail\n", 276 | "- Length: 7.5 miles round trip\n", 277 | "- Interesting fact: At the summit, you'll find the Mount Beacon Fire Tower, which was built in 1931 and restored in 2013. Climbing the tower provides panoramic views of the Hudson Valley and the Catskill Mountains.\n", 278 | "\n", 279 | "Remember to always hike responsibly, bring plenty of water, and wear appropriate footwear. Enjoy your hikes in the beautiful Hudson Valley!\r\n" 280 | ] 281 | } 282 | ], 283 | "source": [ 284 | "chat \"I'm a few miles from Beacon, NY and would like to see all types of intensities.\"" 285 | ] 286 | } 287 | ], 288 | "metadata": { 289 | "kernelspec": { 290 | "display_name": ".NET (PowerShell)", 291 | "language": "PowerShell", 292 | "name": ".net-pwsh" 293 | }, 294 | "language_info": { 295 | "name": "polyglot-notebook" 296 | }, 297 | "polyglot_notebook": { 298 | "kernelInfo": { 299 | "defaultKernelName": "pwsh", 300 | "items": [ 301 | { 302 | "aliases": [], 303 | "languageName": "pwsh", 304 | "name": "pwsh" 305 | } 306 | ] 307 | } 308 | } 309 | }, 310 | "nbformat": 4, 311 | "nbformat_minor": 2 312 | } 313 | --------------------------------------------------------------------------------