├── .devcontainer.json ├── .gitignore ├── PE-ChatBot.ipynb ├── PE-Expanding.ipynb ├── PE-Inferring.ipynb ├── PE-Iterative.ipynb ├── PE-OrderBot.ipynb ├── PE-Summarizing.ipynb ├── PE-Transforming.ipynb ├── readme.md └── required-libraries.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 | ] 8 | } 9 | }, 10 | "containerEnv": { 11 | "AOAI_DEPLOYMENTID": "", 12 | "AOAI_ENDPOINT": "", 13 | "AOAI_KEY": "" 14 | }, 15 | "postStartCommand": "bash download-vocab-files.sh" 16 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env_x 3 | .ipynb_checkpoints 4 | llama_index 5 | webstorage_Surface* 6 | -------------------------------------------------------------------------------- /PE-ChatBot.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "Prompt Engineering\n", 9 | "\n", 10 | "**Chatbot**: Chat using system, user, and assistant message roles." 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": { 17 | "dotnet_interactive": { 18 | "language": "csharp" 19 | }, 20 | "polyglot_notebook": { 21 | "kernelName": "csharp" 22 | }, 23 | "vscode": { 24 | "languageId": "polyglot-notebook" 25 | } 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "#r \"nuget:dotenv.net\"\n", 30 | "#r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 31 | "#!import ./required-libraries.ipynb" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": { 38 | "dotnet_interactive": { 39 | "language": "csharp" 40 | }, 41 | "polyglot_notebook": { 42 | "kernelName": "csharp" 43 | }, 44 | "vscode": { 45 | "languageId": "polyglot-notebook" 46 | } 47 | }, 48 | "outputs": [], 49 | "source": [ 50 | "var endpoint = new Uri(AOAI_ENDPOINT);\n", 51 | "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", 52 | "var openAIClient = new OpenAIClient(endpoint, credentials);" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "dotnet_interactive": { 60 | "language": "csharp" 61 | }, 62 | "polyglot_notebook": { 63 | "kernelName": "csharp" 64 | }, 65 | "vscode": { 66 | "languageId": "polyglot-notebook" 67 | } 68 | }, 69 | "outputs": [], 70 | "source": [ 71 | "var completionOptions = new ChatCompletionsOptions\n", 72 | "{\n", 73 | " MaxTokens=150,\n", 74 | " Temperature=0.0f,\n", 75 | " FrequencyPenalty=0.0f,\n", 76 | " PresencePenalty=0.0f,\n", 77 | "};\n", 78 | "\n", 79 | "completionOptions.Messages.Add(new ChatMessage(\"system\", \"You are an assistant that speaks like Shakespeare.\"));\n", 80 | "completionOptions.Messages.Add(new ChatMessage(\"user\", \"tell me a joke\"));\n", 81 | "completionOptions.Messages.Add(new ChatMessage(\"assistant\", \"why did the chicken cross the road\"));\n", 82 | "completionOptions.Messages.Add(new ChatMessage(\"user\", \"I don't know\"));\n" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": null, 88 | "metadata": { 89 | "dotnet_interactive": { 90 | "language": "csharp" 91 | }, 92 | "polyglot_notebook": { 93 | "kernelName": "csharp" 94 | }, 95 | "vscode": { 96 | "languageId": "polyglot-notebook" 97 | } 98 | }, 99 | "outputs": [], 100 | "source": [ 101 | "ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "metadata": { 108 | "dotnet_interactive": { 109 | "language": "csharp" 110 | }, 111 | "polyglot_notebook": { 112 | "kernelName": "csharp" 113 | }, 114 | "vscode": { 115 | "languageId": "polyglot-notebook" 116 | } 117 | }, 118 | "outputs": [], 119 | "source": [ 120 | "response.Choices[0].Message.Content" 121 | ] 122 | } 123 | ], 124 | "metadata": { 125 | "language_info": { 126 | "name": "csharp" 127 | }, 128 | "orig_nbformat": 4 129 | }, 130 | "nbformat": 4, 131 | "nbformat_minor": 2 132 | } 133 | -------------------------------------------------------------------------------- /PE-Expanding.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "Prompt Engineering\n", 9 | "\n", 10 | "**Expanding**: Generate text based on tone and sentiment of input\n" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": { 17 | "dotnet_interactive": { 18 | "language": "csharp" 19 | }, 20 | "polyglot_notebook": { 21 | "kernelName": "csharp" 22 | }, 23 | "vscode": { 24 | "languageId": "polyglot-notebook" 25 | } 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "#r \"nuget:dotenv.net\"\n", 30 | "#r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 31 | "#!import ./required-libraries.ipynb" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": { 38 | "dotnet_interactive": { 39 | "language": "csharp" 40 | }, 41 | "polyglot_notebook": { 42 | "kernelName": "csharp" 43 | }, 44 | "vscode": { 45 | "languageId": "polyglot-notebook" 46 | } 47 | }, 48 | "outputs": [], 49 | "source": [ 50 | "var endpoint = new Uri(AOAI_ENDPOINT);\n", 51 | "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", 52 | "var openAIClient = new OpenAIClient(endpoint, credentials);" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "dotnet_interactive": { 60 | "language": "csharp" 61 | }, 62 | "polyglot_notebook": { 63 | "kernelName": "csharp" 64 | }, 65 | "vscode": { 66 | "languageId": "polyglot-notebook" 67 | } 68 | }, 69 | "outputs": [], 70 | "source": [ 71 | "// given the sentiment from the lesson on \"inferring\",\n", 72 | "// and the original customer message, customize the email\n", 73 | "var sentiment = \"negative\";\n", 74 | "\n", 75 | "var review = \"\"\"\n", 76 | "So, they still had the 17 piece system on seasonal \\\n", 77 | "sale for around $49 in the month of November, about \\\n", 78 | "half off, but for some reason (call it price gouging) \\\n", 79 | "around the second week of December the prices all went \\\n", 80 | "up to about anywhere from between $70-$89 for the same \\\n", 81 | "system. And the 11 piece system went up around $10 or \\\n", 82 | "so in price also from the earlier sale price of $29. \\\n", 83 | "So it looks okay, but if you look at the base, the part \\\n", 84 | "where the blade locks into place doesn’t look as good \\\n", 85 | "as in previous editions from a few years ago, but I \\\n", 86 | "plan to be very gentle with it (example, I crush \\\n", 87 | "very hard items like beans, ice, rice, etc. in the \\ \n", 88 | "blender first then pulverize them in the serving size \\\n", 89 | "I want in the blender then switch to the whipping \\\n", 90 | "blade for a finer flour, and use the cross cutting blade \\\n", 91 | "first when making smoothies, then use the flat blade \\\n", 92 | "if I need them finer/less pulpy). Special tip when making \\\n", 93 | "smoothies, finely cut and freeze the fruits and \\\n", 94 | "vegetables (if using spinach-lightly stew soften the \\ \n", 95 | "spinach then freeze until ready for use-and if making \\\n", 96 | "sorbet, use a small to medium sized food processor) \\ \n", 97 | "that you plan to use that way you can avoid adding so \\\n", 98 | "much ice if at all-when making your smoothie. \\\n", 99 | "After about a year, the motor was making a funny noise. \\\n", 100 | "I called customer service but the warranty expired \\\n", 101 | "already, so I had to buy another one. FYI: The overall \\\n", 102 | "quality has gone done in these types of products, so \\\n", 103 | "they are kind of counting on brand recognition and \\\n", 104 | "consumer loyalty to maintain sales. Got it in about \\\n", 105 | "two days.\n", 106 | "\"\"\";" 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": null, 112 | "metadata": { 113 | "dotnet_interactive": { 114 | "language": "csharp" 115 | }, 116 | "polyglot_notebook": { 117 | "kernelName": "csharp" 118 | }, 119 | "vscode": { 120 | "languageId": "polyglot-notebook" 121 | } 122 | }, 123 | "outputs": [], 124 | "source": [ 125 | "var prompt = $\"\"\"\n", 126 | "You are a customer service AI assistant.\n", 127 | "Your task is to send an email reply to a valued customer.\n", 128 | "Given the customer email delimited by ```, \\\n", 129 | "Generate a reply to thank the customer for their review.\n", 130 | "If the sentiment is positive or neutral, thank them for \\\n", 131 | "their review.\n", 132 | "If the sentiment is negative, apologize and suggest that \\\n", 133 | "they can reach out to customer service. \n", 134 | "Make sure to use specific details from the review.\n", 135 | "Write in a concise and professional tone.\n", 136 | "Sign the email as `AI customer agent`.\n", 137 | "Customer review: ```{review}```\n", 138 | "Review sentiment: {sentiment}\n", 139 | "\"\"\";" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": null, 145 | "metadata": { 146 | "dotnet_interactive": { 147 | "language": "csharp" 148 | }, 149 | "polyglot_notebook": { 150 | "kernelName": "csharp" 151 | }, 152 | "vscode": { 153 | "languageId": "polyglot-notebook" 154 | } 155 | }, 156 | "outputs": [], 157 | "source": [ 158 | "var completionOptions = new ChatCompletionsOptions\n", 159 | "{\n", 160 | " MaxTokens=150,\n", 161 | " Temperature=0.0f,\n", 162 | " FrequencyPenalty=0.0f,\n", 163 | " PresencePenalty=0.0f,\n", 164 | "};\n", 165 | "completionOptions.Messages.Add(new ChatMessage(\"user\", prompt));" 166 | ] 167 | }, 168 | { 169 | "cell_type": "code", 170 | "execution_count": null, 171 | "metadata": { 172 | "dotnet_interactive": { 173 | "language": "csharp" 174 | }, 175 | "polyglot_notebook": { 176 | "kernelName": "csharp" 177 | }, 178 | "vscode": { 179 | "languageId": "polyglot-notebook" 180 | } 181 | }, 182 | "outputs": [], 183 | "source": [ 184 | "ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);" 185 | ] 186 | }, 187 | { 188 | "cell_type": "code", 189 | "execution_count": null, 190 | "metadata": { 191 | "dotnet_interactive": { 192 | "language": "csharp" 193 | }, 194 | "polyglot_notebook": { 195 | "kernelName": "csharp" 196 | }, 197 | "vscode": { 198 | "languageId": "polyglot-notebook" 199 | } 200 | }, 201 | "outputs": [], 202 | "source": [ 203 | "response.Choices[0].Message.Content" 204 | ] 205 | } 206 | ], 207 | "metadata": { 208 | "language_info": { 209 | "name": "csharp" 210 | }, 211 | "orig_nbformat": 4 212 | }, 213 | "nbformat": 4, 214 | "nbformat_minor": 2 215 | } 216 | -------------------------------------------------------------------------------- /PE-Inferring.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "Prompt Engineering\n", 9 | "\n", 10 | "**Inferring**: Sentiment Analysis, Emotion detection, Entity Extraction\n" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": { 17 | "dotnet_interactive": { 18 | "language": "csharp" 19 | }, 20 | "polyglot_notebook": { 21 | "kernelName": "csharp" 22 | }, 23 | "vscode": { 24 | "languageId": "polyglot-notebook" 25 | } 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "#r \"nuget:dotenv.net\"\n", 30 | "#r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 31 | "#!import ./required-libraries.ipynb" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": { 38 | "dotnet_interactive": { 39 | "language": "csharp" 40 | }, 41 | "polyglot_notebook": { 42 | "kernelName": "csharp" 43 | }, 44 | "vscode": { 45 | "languageId": "polyglot-notebook" 46 | } 47 | }, 48 | "outputs": [], 49 | "source": [ 50 | "var endpoint = new Uri(AOAI_ENDPOINT);\n", 51 | "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", 52 | "var openAIClient = new OpenAIClient(endpoint, credentials);" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "dotnet_interactive": { 60 | "language": "csharp" 61 | }, 62 | "polyglot_notebook": { 63 | "kernelName": "csharp" 64 | }, 65 | "vscode": { 66 | "languageId": "polyglot-notebook" 67 | } 68 | }, 69 | "outputs": [], 70 | "source": [ 71 | "var lamp_review = \"\"\"\n", 72 | "Needed a nice lamp for my bedroom, and this one had \\\n", 73 | "additional storage and not too high of a price point. \\\n", 74 | "Got it fast. The string to our lamp broke during the \\\n", 75 | "transit and the company happily sent over a new one. \\\n", 76 | "Came within a few days as well. It was easy to put \\\n", 77 | "together. I had a missing part, so I contacted their \\\n", 78 | "support and they very quickly got me the missing piece! \\\n", 79 | "Lumina seems to me to be a great company that cares \\\n", 80 | "about their customers and products!!\n", 81 | "\"\"\";" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "execution_count": null, 87 | "metadata": { 88 | "dotnet_interactive": { 89 | "language": "csharp" 90 | }, 91 | "polyglot_notebook": { 92 | "kernelName": "csharp" 93 | }, 94 | "vscode": { 95 | "languageId": "polyglot-notebook" 96 | } 97 | }, 98 | "outputs": [], 99 | "source": [ 100 | "var prompt = $\"\"\"\n", 101 | "Identify the following items from the review text: \n", 102 | "- Sentiment (positive or negative)\n", 103 | "- Is the reviewer expressing anger? (true or false)\n", 104 | "- Item purchased by reviewer\n", 105 | "- Company that made the item\n", 106 | "\n", 107 | "The review is delimited with triple backticks. \\\n", 108 | "Format your response as a JSON object with \\\n", 109 | "\"Sentiment\", \"Anger\", \"Item\" and \"Brand\" as the keys.\n", 110 | "If the information isn't present, use \"unknown\" \\\n", 111 | "as the value.\n", 112 | "Make your response as short as possible.\n", 113 | "Format the Anger value as a boolean.\n", 114 | "\n", 115 | "Review text: '''{lamp_review}'''\n", 116 | "\"\"\";" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "metadata": { 123 | "dotnet_interactive": { 124 | "language": "csharp" 125 | }, 126 | "polyglot_notebook": { 127 | "kernelName": "csharp" 128 | }, 129 | "vscode": { 130 | "languageId": "polyglot-notebook" 131 | } 132 | }, 133 | "outputs": [], 134 | "source": [ 135 | "var completionOptions = new ChatCompletionsOptions\n", 136 | "{\n", 137 | " MaxTokens=150,\n", 138 | " Temperature=0.0f,\n", 139 | " FrequencyPenalty=0.0f,\n", 140 | " PresencePenalty=0.0f,\n", 141 | "};\n", 142 | "completionOptions.Messages.Add(new ChatMessage(\"user\", prompt));" 143 | ] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": null, 148 | "metadata": { 149 | "dotnet_interactive": { 150 | "language": "csharp" 151 | }, 152 | "polyglot_notebook": { 153 | "kernelName": "csharp" 154 | }, 155 | "vscode": { 156 | "languageId": "polyglot-notebook" 157 | } 158 | }, 159 | "outputs": [], 160 | "source": [ 161 | "ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);" 162 | ] 163 | }, 164 | { 165 | "cell_type": "code", 166 | "execution_count": null, 167 | "metadata": { 168 | "dotnet_interactive": { 169 | "language": "csharp" 170 | }, 171 | "polyglot_notebook": { 172 | "kernelName": "csharp" 173 | }, 174 | "vscode": { 175 | "languageId": "polyglot-notebook" 176 | } 177 | }, 178 | "outputs": [], 179 | "source": [ 180 | "response.Choices[0].Message.Content" 181 | ] 182 | } 183 | ], 184 | "metadata": { 185 | "language_info": { 186 | "name": "csharp" 187 | }, 188 | "orig_nbformat": 4 189 | }, 190 | "nbformat": 4, 191 | "nbformat_minor": 2 192 | } 193 | -------------------------------------------------------------------------------- /PE-Iterative.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "# Iterative Prompt Development\n", 9 | "In this lesson, you'll iteratively analyze and refine your prompts to generate marketing copy from a product fact sheet.\n" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "dotnet_interactive": { 17 | "language": "csharp" 18 | }, 19 | "polyglot_notebook": { 20 | "kernelName": "csharp" 21 | }, 22 | "vscode": { 23 | "languageId": "polyglot-notebook" 24 | } 25 | }, 26 | "outputs": [], 27 | "source": [ 28 | "#r \"nuget:dotenv.net\"\n", 29 | "#r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 30 | "#!import ./required-libraries.ipynb" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": { 37 | "dotnet_interactive": { 38 | "language": "csharp" 39 | }, 40 | "polyglot_notebook": { 41 | "kernelName": "csharp" 42 | }, 43 | "vscode": { 44 | "languageId": "polyglot-notebook" 45 | } 46 | }, 47 | "outputs": [], 48 | "source": [ 49 | "var endpoint = new Uri(AOAI_ENDPOINT);\n", 50 | "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", 51 | "var openAIClient = new OpenAIClient(endpoint, credentials);" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": null, 57 | "metadata": { 58 | "dotnet_interactive": { 59 | "language": "csharp" 60 | }, 61 | "polyglot_notebook": { 62 | "kernelName": "csharp" 63 | }, 64 | "vscode": { 65 | "languageId": "polyglot-notebook" 66 | } 67 | }, 68 | "outputs": [], 69 | "source": [ 70 | "var fact_sheet_chair = \"\"\"\n", 71 | "OVERVIEW\n", 72 | "- Part of a beautiful family of mid-century inspired office furniture, \n", 73 | "including filing cabinets, desks, bookcases, meeting tables, and more.\n", 74 | "- Several options of shell color and base finishes.\n", 75 | "- Available with plastic back and front upholstery (SWC-100) \n", 76 | "or full upholstery (SWC-110) in 10 fabric and 6 leather options.\n", 77 | "- Base finish options are: stainless steel, matte black, \n", 78 | "gloss white, or chrome.\n", 79 | "- Chair is available with or without armrests.\n", 80 | "- Suitable for home or business settings.\n", 81 | "- Qualified for contract use.\n", 82 | "\n", 83 | "CONSTRUCTION\n", 84 | "- 5-wheel plastic coated aluminum base.\n", 85 | "- Pneumatic chair adjust for easy raise/lower action.\n", 86 | "\n", 87 | "DIMENSIONS\n", 88 | "- WIDTH 53 CM | 20.87”\n", 89 | "- DEPTH 51 CM | 20.08”\n", 90 | "- HEIGHT 80 CM | 31.50”\n", 91 | "- SEAT HEIGHT 44 CM | 17.32”\n", 92 | "- SEAT DEPTH 41 CM | 16.14”\n", 93 | "\n", 94 | "OPTIONS\n", 95 | "- Soft or hard-floor caster options.\n", 96 | "- Two choices of seat foam densities: \n", 97 | " medium (1.8 lb/ft3) or high (2.8 lb/ft3)\n", 98 | "- Armless or 8 position PU armrests \n", 99 | "\n", 100 | "MATERIALS\n", 101 | "SHELL BASE GLIDER\n", 102 | "- Cast Aluminum with modified nylon PA6/PA66 coating.\n", 103 | "- Shell thickness: 10 mm.\n", 104 | "SEAT\n", 105 | "- HD36 foam\n", 106 | "\n", 107 | "COUNTRY OF ORIGIN\n", 108 | "- Italy\n", 109 | "\"\"\";" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": null, 115 | "metadata": { 116 | "dotnet_interactive": { 117 | "language": "csharp" 118 | }, 119 | "polyglot_notebook": { 120 | "kernelName": "csharp" 121 | }, 122 | "vscode": { 123 | "languageId": "polyglot-notebook" 124 | } 125 | }, 126 | "outputs": [], 127 | "source": [ 128 | "var prompt = $\"\"\"\n", 129 | "Your task is to help a marketing team create a \n", 130 | "description for a retail website of a product based \n", 131 | "on a technical fact sheet.\n", 132 | "\n", 133 | "Write a product description based on the information \n", 134 | "provided in the technical specifications delimited by \n", 135 | "triple backticks.\n", 136 | "\n", 137 | "Use at most 50 words.\n", 138 | "\n", 139 | "Technical specifications: ```{fact_sheet_chair}```\n", 140 | "\"\"\";" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": null, 146 | "metadata": { 147 | "dotnet_interactive": { 148 | "language": "csharp" 149 | }, 150 | "polyglot_notebook": { 151 | "kernelName": "csharp" 152 | }, 153 | "vscode": { 154 | "languageId": "polyglot-notebook" 155 | } 156 | }, 157 | "outputs": [], 158 | "source": [ 159 | "var completionOptions = new ChatCompletionsOptions\n", 160 | "{\n", 161 | " MaxTokens=150,\n", 162 | " Temperature=0.3f,\n", 163 | " FrequencyPenalty=0.0f,\n", 164 | " PresencePenalty=0.0f,\n", 165 | "};\n", 166 | "completionOptions.Messages.Add(new ChatMessage(\"user\", prompt));" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": { 173 | "dotnet_interactive": { 174 | "language": "csharp" 175 | }, 176 | "polyglot_notebook": { 177 | "kernelName": "csharp" 178 | }, 179 | "vscode": { 180 | "languageId": "polyglot-notebook" 181 | } 182 | }, 183 | "outputs": [], 184 | "source": [ 185 | "ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);" 186 | ] 187 | }, 188 | { 189 | "cell_type": "code", 190 | "execution_count": null, 191 | "metadata": { 192 | "dotnet_interactive": { 193 | "language": "csharp" 194 | }, 195 | "polyglot_notebook": { 196 | "kernelName": "csharp" 197 | }, 198 | "vscode": { 199 | "languageId": "polyglot-notebook" 200 | } 201 | }, 202 | "outputs": [], 203 | "source": [ 204 | "response.Choices[0].Message.Content" 205 | ] 206 | } 207 | ], 208 | "metadata": { 209 | "language_info": { 210 | "name": "csharp" 211 | }, 212 | "orig_nbformat": 4 213 | }, 214 | "nbformat": 4, 215 | "nbformat_minor": 2 216 | } 217 | -------------------------------------------------------------------------------- /PE-OrderBot.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "Prompt Engineering\n", 9 | "\n", 10 | "**Orderbot**: Interactive chat using turn-based input to add to context\n" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": { 17 | "dotnet_interactive": { 18 | "language": "csharp" 19 | }, 20 | "polyglot_notebook": { 21 | "kernelName": "csharp" 22 | }, 23 | "vscode": { 24 | "languageId": "polyglot-notebook" 25 | } 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "#r \"nuget:dotenv.net\"\n", 30 | "#r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 31 | "#!import ./required-libraries.ipynb\n", 32 | "using Microsoft.DotNet.Interactive;" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": null, 38 | "metadata": { 39 | "dotnet_interactive": { 40 | "language": "csharp" 41 | }, 42 | "polyglot_notebook": { 43 | "kernelName": "csharp" 44 | }, 45 | "vscode": { 46 | "languageId": "polyglot-notebook" 47 | } 48 | }, 49 | "outputs": [], 50 | "source": [ 51 | "var endpoint = new Uri(AOAI_ENDPOINT);\n", 52 | "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", 53 | "var openAIClient = new OpenAIClient(endpoint, credentials);" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": null, 59 | "metadata": { 60 | "dotnet_interactive": { 61 | "language": "csharp" 62 | }, 63 | "polyglot_notebook": { 64 | "kernelName": "csharp" 65 | }, 66 | "vscode": { 67 | "languageId": "polyglot-notebook" 68 | } 69 | }, 70 | "outputs": [], 71 | "source": [ 72 | "var userinput = await Kernel.GetInputAsync(\"userinput\");\n", 73 | "\n", 74 | "Console.WriteLine(userinput);\n" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": null, 80 | "metadata": { 81 | "dotnet_interactive": { 82 | "language": "csharp" 83 | }, 84 | "polyglot_notebook": { 85 | "kernelName": "csharp" 86 | }, 87 | "vscode": { 88 | "languageId": "polyglot-notebook" 89 | } 90 | }, 91 | "outputs": [], 92 | "source": [ 93 | "var context = \"\"\"\n", 94 | "You are OrderBot, an automated service to collect orders for a pizza restaurant. \\\n", 95 | "You first greet the customer, then collects the order, \\\n", 96 | "and then asks if it's a pickup or delivery. \\\n", 97 | "You wait to collect the entire order, then summarize it and check for a final \\\n", 98 | "time if the customer wants to add anything else. \\\n", 99 | "If it's a delivery, you ask for an address. \\\n", 100 | "Finally you collect the payment.\\\n", 101 | "Make sure to clarify all options, extras and sizes to uniquely \\\n", 102 | "identify the item from the menu.\\\n", 103 | "You respond in a short, very conversational friendly style. \\\n", 104 | "The menu includes \\\n", 105 | "pepperoni pizza 12.95, 10.00, 7.00 \\\n", 106 | "cheese pizza 10.95, 9.25, 6.50 \\\n", 107 | "eggplant pizza 11.95, 9.75, 6.75 \\\n", 108 | "fries 4.50, 3.50 \\\n", 109 | "greek salad 7.25 \\\n", 110 | "Toppings: \\\n", 111 | "extra cheese 2.00, \\\n", 112 | "mushrooms 1.50 \\\n", 113 | "sausage 3.00 \\\n", 114 | "canadian bacon 3.50 \\\n", 115 | "AI sauce 1.50 \\\n", 116 | "peppers 1.00 \\\n", 117 | "Drinks: \\\n", 118 | "coke 3.00, 2.00, 1.00 \\\n", 119 | "sprite 3.00, 2.00, 1.00 \\\n", 120 | "bottled water 5.00 \\\n", 121 | "\"\"\";" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": null, 127 | "metadata": { 128 | "dotnet_interactive": { 129 | "language": "csharp" 130 | }, 131 | "polyglot_notebook": { 132 | "kernelName": "csharp" 133 | }, 134 | "vscode": { 135 | "languageId": "polyglot-notebook" 136 | } 137 | }, 138 | "outputs": [], 139 | "source": [ 140 | "var completionOptions = new ChatCompletionsOptions\n", 141 | "{\n", 142 | " MaxTokens=150,\n", 143 | " Temperature=0.0f,\n", 144 | " FrequencyPenalty=0.0f,\n", 145 | " PresencePenalty=0.0f,\n", 146 | "};\n", 147 | "\n", 148 | "completionOptions.Messages.Add(new ChatMessage(\"system\", context));" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": null, 154 | "metadata": { 155 | "dotnet_interactive": { 156 | "language": "csharp" 157 | }, 158 | "polyglot_notebook": { 159 | "kernelName": "csharp" 160 | }, 161 | "vscode": { 162 | "languageId": "polyglot-notebook" 163 | } 164 | }, 165 | "outputs": [], 166 | "source": [ 167 | "ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);" 168 | ] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": null, 173 | "metadata": { 174 | "dotnet_interactive": { 175 | "language": "csharp" 176 | }, 177 | "polyglot_notebook": { 178 | "kernelName": "csharp" 179 | }, 180 | "vscode": { 181 | "languageId": "polyglot-notebook" 182 | } 183 | }, 184 | "outputs": [], 185 | "source": [ 186 | "response.Choices[0].Message.Content" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": null, 192 | "metadata": { 193 | "dotnet_interactive": { 194 | "language": "csharp" 195 | }, 196 | "polyglot_notebook": { 197 | "kernelName": "csharp" 198 | }, 199 | "vscode": { 200 | "languageId": "polyglot-notebook" 201 | } 202 | }, 203 | "outputs": [], 204 | "source": [ 205 | "while (userinput != \"quit\" )\n", 206 | "{\n", 207 | " completionOptions.Messages.Add(new ChatMessage(\"user\", userinput));\n", 208 | " ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);\n", 209 | " Console.WriteLine(response.Choices[0].Message.Content);\n", 210 | " userinput = await Kernel.GetInputAsync(\"userinput\");\n", 211 | "}" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": null, 217 | "metadata": { 218 | "dotnet_interactive": { 219 | "language": "csharp" 220 | }, 221 | "polyglot_notebook": { 222 | "kernelName": "csharp" 223 | }, 224 | "vscode": { 225 | "languageId": "polyglot-notebook" 226 | } 227 | }, 228 | "outputs": [], 229 | "source": [ 230 | "Console.WriteLine(\"Thanks for your order!\");" 231 | ] 232 | } 233 | ], 234 | "metadata": { 235 | "language_info": { 236 | "name": "csharp" 237 | }, 238 | "orig_nbformat": 4 239 | }, 240 | "nbformat": 4, 241 | "nbformat_minor": 2 242 | } 243 | -------------------------------------------------------------------------------- /PE-Summarizing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "Prompt Engineering\n", 9 | "\n", 10 | "Summarizing: Providing summarized output\n" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": { 17 | "dotnet_interactive": { 18 | "language": "csharp" 19 | }, 20 | "polyglot_notebook": { 21 | "kernelName": "csharp" 22 | }, 23 | "vscode": { 24 | "languageId": "polyglot-notebook" 25 | } 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "#r \"nuget:dotenv.net\"\n", 30 | "#r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 31 | "#!import ./required-libraries.ipynb" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": { 38 | "dotnet_interactive": { 39 | "language": "csharp" 40 | }, 41 | "polyglot_notebook": { 42 | "kernelName": "csharp" 43 | }, 44 | "vscode": { 45 | "languageId": "polyglot-notebook" 46 | } 47 | }, 48 | "outputs": [], 49 | "source": [ 50 | "var endpoint = new Uri(AOAI_ENDPOINT);\n", 51 | "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", 52 | "var openAIClient = new OpenAIClient(endpoint, credentials);" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "dotnet_interactive": { 60 | "language": "csharp" 61 | }, 62 | "polyglot_notebook": { 63 | "kernelName": "csharp" 64 | }, 65 | "vscode": { 66 | "languageId": "polyglot-notebook" 67 | } 68 | }, 69 | "outputs": [], 70 | "source": [ 71 | "var prod_review = \"\"\"\n", 72 | "Got this panda plush toy for my daughter's birthday, \\\n", 73 | "who loves it and takes it everywhere. It's soft and \\ \n", 74 | "super cute, and its face has a friendly look. It's \\ \n", 75 | "a bit small for what I paid though. I think there \\ \n", 76 | "might be other options that are bigger for the \\ \n", 77 | "same price. It arrived a day earlier than expected, \\ \n", 78 | "so I got to play with it myself before I gave it \\ \n", 79 | "to her.\n", 80 | "\"\"\";" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": { 87 | "dotnet_interactive": { 88 | "language": "csharp" 89 | }, 90 | "polyglot_notebook": { 91 | "kernelName": "csharp" 92 | }, 93 | "vscode": { 94 | "languageId": "polyglot-notebook" 95 | } 96 | }, 97 | "outputs": [], 98 | "source": [ 99 | "var prompt = $\"\"\"\n", 100 | "Your task is to extract relevant information from \\ \n", 101 | "a product review from an ecommerce site to give \\\n", 102 | "feedback to the Shipping department. \n", 103 | "\n", 104 | "From the review below, delimited by triple quotes \\\n", 105 | "extract the information relevant to shipping and \\ \n", 106 | "delivery. Limit to 30 words. \n", 107 | "\n", 108 | "Review: ```{prod_review}```\n", 109 | "\"\"\";" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": null, 115 | "metadata": { 116 | "dotnet_interactive": { 117 | "language": "csharp" 118 | }, 119 | "polyglot_notebook": { 120 | "kernelName": "csharp" 121 | }, 122 | "vscode": { 123 | "languageId": "polyglot-notebook" 124 | } 125 | }, 126 | "outputs": [], 127 | "source": [ 128 | "var completionOptions = new ChatCompletionsOptions\n", 129 | "{\n", 130 | " MaxTokens=150,\n", 131 | " Temperature=0.0f,\n", 132 | " FrequencyPenalty=0.0f,\n", 133 | " PresencePenalty=0.0f,\n", 134 | "};\n", 135 | "completionOptions.Messages.Add(new ChatMessage(\"user\", prompt));" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": null, 141 | "metadata": { 142 | "dotnet_interactive": { 143 | "language": "csharp" 144 | }, 145 | "polyglot_notebook": { 146 | "kernelName": "csharp" 147 | }, 148 | "vscode": { 149 | "languageId": "polyglot-notebook" 150 | } 151 | }, 152 | "outputs": [], 153 | "source": [ 154 | "ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": null, 160 | "metadata": { 161 | "dotnet_interactive": { 162 | "language": "csharp" 163 | }, 164 | "polyglot_notebook": { 165 | "kernelName": "csharp" 166 | }, 167 | "vscode": { 168 | "languageId": "polyglot-notebook" 169 | } 170 | }, 171 | "outputs": [], 172 | "source": [ 173 | "response.Choices[0].Message.Content" 174 | ] 175 | } 176 | ], 177 | "metadata": { 178 | "language_info": { 179 | "name": "csharp" 180 | }, 181 | "orig_nbformat": 4 182 | }, 183 | "nbformat": 4, 184 | "nbformat_minor": 2 185 | } 186 | -------------------------------------------------------------------------------- /PE-Transforming.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "attachments": {}, 5 | "cell_type": "markdown", 6 | "metadata": {}, 7 | "source": [ 8 | "Prompt Engineering\n", 9 | "\n", 10 | "**Iterative**: Modifying the prompt until it gives you the correct output\n" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": null, 16 | "metadata": { 17 | "dotnet_interactive": { 18 | "language": "csharp" 19 | }, 20 | "polyglot_notebook": { 21 | "kernelName": "csharp" 22 | }, 23 | "vscode": { 24 | "languageId": "polyglot-notebook" 25 | } 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "#r \"nuget:dotenv.net\"\n", 30 | "#r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 31 | "#!import ./required-libraries.ipynb" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": null, 37 | "metadata": { 38 | "dotnet_interactive": { 39 | "language": "csharp" 40 | }, 41 | "polyglot_notebook": { 42 | "kernelName": "csharp" 43 | }, 44 | "vscode": { 45 | "languageId": "polyglot-notebook" 46 | } 47 | }, 48 | "outputs": [], 49 | "source": [ 50 | "var endpoint = new Uri(AOAI_ENDPOINT);\n", 51 | "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", 52 | "var openAIClient = new OpenAIClient(endpoint, credentials);" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "dotnet_interactive": { 60 | "language": "csharp" 61 | }, 62 | "polyglot_notebook": { 63 | "kernelName": "csharp" 64 | }, 65 | "vscode": { 66 | "languageId": "polyglot-notebook" 67 | } 68 | }, 69 | "outputs": [], 70 | "source": [ 71 | "var promptArray = new string[] { $\"\"\"\n", 72 | "Translate the following English text to Spanish: \\ \n", 73 | "```Hi, I would like to order a blender```\n", 74 | "\"\"\",\n", 75 | "$\"\"\"\n", 76 | "Tell me which language this is: \n", 77 | "```Combien coûte le lampadaire?```\n", 78 | "\"\"\",\n", 79 | "$\"\"\"\n", 80 | "Translate the following text to French and Spanish\n", 81 | "and English pirate: \\\n", 82 | "```I want to order a basketball``\n", 83 | "\"\"\",\n", 84 | "$\"\"\"\n", 85 | "Translate the following text to Spanish in both the \\\n", 86 | "formal and informal forms: \n", 87 | "'Would you like to order a pillow?'\n", 88 | "\"\"\"\n", 89 | "\n", 90 | "};\n", 91 | "\n" 92 | ] 93 | }, 94 | { 95 | "cell_type": "code", 96 | "execution_count": null, 97 | "metadata": { 98 | "dotnet_interactive": { 99 | "language": "csharp" 100 | }, 101 | "polyglot_notebook": { 102 | "kernelName": "csharp" 103 | }, 104 | "vscode": { 105 | "languageId": "polyglot-notebook" 106 | } 107 | }, 108 | "outputs": [], 109 | "source": [ 110 | "var completionOptions = new ChatCompletionsOptions\n", 111 | "{\n", 112 | " MaxTokens=150,\n", 113 | " Temperature=0.0f,\n", 114 | " FrequencyPenalty=0.0f,\n", 115 | " PresencePenalty=0.0f,\n", 116 | "};" 117 | ] 118 | }, 119 | { 120 | "cell_type": "code", 121 | "execution_count": null, 122 | "metadata": { 123 | "dotnet_interactive": { 124 | "language": "csharp" 125 | }, 126 | "polyglot_notebook": { 127 | "kernelName": "csharp" 128 | }, 129 | "vscode": { 130 | "languageId": "polyglot-notebook" 131 | } 132 | }, 133 | "outputs": [], 134 | "source": [ 135 | "foreach (var str in promptArray)\n", 136 | "{\n", 137 | " completionOptions.Messages.Add(new ChatMessage(\"user\", str));\n", 138 | " ChatCompletions response = openAIClient.GetChatCompletions(AOAI_DEPLOYMENTID,completionOptions);\n", 139 | " Console.WriteLine(str);\n", 140 | " Console.WriteLine(response.Choices[0].Message.Content + \"\\n\");\n", 141 | "}\n" 142 | ] 143 | } 144 | ], 145 | "metadata": { 146 | "language_info": { 147 | "name": "csharp" 148 | }, 149 | "orig_nbformat": 4 150 | }, 151 | "nbformat": 4, 152 | "nbformat_minor": 2 153 | } 154 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Azure OpenAI C# Prompt Engineering Samples 2 | 3 | This project is a port of the [ChatGPT Prompt Engineering for Developers](https://learn.deeplearning.ai/chatgpt-prompt-eng) samples from OpenAI / Python to C# / Azure-OpenAI. It uses [Interactive Notebooks for C#](https://github.com/dotnet/csharp-notebooks), [Azure OpenAI service](https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.openai-readme?view=azure-dotnet-preview), and the [Azure OpenAI client library for .NET](https://www.nuget.org/packages/Azure.AI.OpenAI). 4 | 5 | ## Prerequisites 6 | 7 | 1. Clone this repo locally 8 | 2. In Azure, create **Azure OpenAI Service** resource. After deploying the model, note the model name, you'll need it for the **AOAI_DEPLOYMENTID** environment variable below. 9 | 3. Install the **[Polyglot Notebooks](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode)** extension in Visual Studio Code. 10 | 2. Configure environment variables 11 | 12 | For more details on how to get the values for the variables, see the [Azure OpenAI documentation](https://learn.microsoft.com/azure/cognitive-services/openai/quickstart?tabs=command-line&pivots=programming-language-csharp#retrieve-key-and-endpoint). 13 | 14 | 15 | Set the following environment variables with the required values. (Tip: Create an .env file): 16 | 17 | **AOAI_ENDPOINT** - The endpoint for your Azure OpenAI Service resource. 18 | 19 | **AOAI_KEY** - The access key for your Azure OpenAI Service resource. 20 | 21 | **AOAI_DEPLOYMENTID** - The name of your model deployment (e.g. my-davinci-003-deployment) 22 | 23 | ## Running the Notebooks 24 | 25 | Open a Jupyter Notebook file (links below) in VS Code. You can run and change the code. 26 | 27 | ## Prompt Types 28 | 29 | [**Iterative**](./PE-Iterative.ipynb): Modifying the prompt until it gives you the correct output 30 | 31 | [**Summarizing**](PE-Summarizing.ipynb): Providing summarized output 32 | 33 | [**Inferring**](./PE-Inferring.ipynb): Sentiment Analysis, Emotion detection, Entity Extraction 34 | 35 | [**Transforming**](./PE-Transforming.ipynb): Language translation and detecting 36 | 37 | [**Expanding**](./PE-Expanding.ipynb): Generate text based on tone and sentiment of input 38 | 39 | [**Chatbot**](./PE-ChatBot.ipynb): Chat using system, user, and assistant message roles. 40 | 41 | [**Orderbot**](./PE-Order.ipynb): Interactive chat using turn-based input to add to context 42 | 43 | ## References 44 | 45 | https://learn.deeplearning.ai/chatgpt-prompt-eng 46 | 47 | https://github.com/Azure-Samples/openai-dotnet-samples 48 | 49 | https://learn.microsoft.com/en-us/dotnet/api/overview/azure/ai.openai-readme?view=azure-dotnet-preview 50 | 51 | https://learn.microsoft.com/en-us/dotnet/api/azure.ai.openai?view=azure-dotnet-preview 52 | 53 | https://www.nuget.org/packages/Azure.AI.OpenAI 54 | 55 | https://github.com/dotnet/interactive 56 | 57 | https://github.com/dotnet/csharp-notebooks 58 | 59 | -------------------------------------------------------------------------------- /required-libraries.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "dotnet_interactive": { 8 | "language": "csharp" 9 | }, 10 | "polyglot_notebook": { 11 | "kernelName": "csharp" 12 | }, 13 | "vscode": { 14 | "languageId": "polyglot-notebook" 15 | } 16 | }, 17 | "outputs": [], 18 | "source": [ 19 | "// #r fail in import. bug https://github.com/dotnet/interactive/pull/2982\n", 20 | "// #r \"nuget:dotenv.net\"\n", 21 | "// #r \"nuget:Azure.AI.OpenAI, 1.0.0-beta.5\"\n", 22 | "using System;\n", 23 | "using Azure.AI.OpenAI;\n", 24 | "using dotenv.net;\n", 25 | "\n", 26 | "DotEnv.Load();\n", 27 | "\n", 28 | "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", 29 | "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", 30 | "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" 31 | ] 32 | } 33 | ], 34 | "metadata": { 35 | "language_info": { 36 | "name": "python" 37 | }, 38 | "orig_nbformat": 4 39 | }, 40 | "nbformat": 4, 41 | "nbformat_minor": 2 42 | } 43 | --------------------------------------------------------------------------------