diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..f937e0b --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,6 @@ +{ + "image": "mcr.microsoft.com/dotnet/sdk:7.0", + "extensions": [ + "ms-dotnettools.dotnet-interactive-vscode" + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..154e127 --- /dev/null +++ b/.gitignore @@ -0,0 +1,477 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk diff --git a/README.md b/README.md new file mode 100644 index 0000000..b0e78b1 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# OpenAI .NET Samples + +Collection of samples similar to those in the [OpenAI website](https://platform.openai.com/examples). + +[![Open in Remote - Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Remote%20-%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/azure-search-openai-demo) + +## Prerequisites + +- [Azure Account](https://aka.ms/free) +- Access to [Azure OpenAI](https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal) or [OpenAI](https://openai.com/) +- [Polyglot Noteboks VS Code Extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) + +## Classification + +- [Classification](./classification.ipynb) +- [Extract keywords](./extract-keywords.ipynb) +- [Tweet classifier](./tweet-classifier.ipynb) +- [Advanced tweet classifier](./advanced-tweet-classifier.ipynb) + +## Generation + +- [Q&A](./qna.ipynb) +- [Grammar correction](./grammar-correction.ipynb) +- [Summarize for 2nd grader](./summarize-second-grader.ipynb) +- [Text to command](./text-to-command.ipynb) +- [Ad from product description](./ad-product-description.ipynb) +- [Product name generator](./product-name-generator.ipynb) +- [TL;DR summarization](./tldr-summarization.ipynb) +- [Science finction book list maker](./science-fiction-book-list-maker.ipynb) +- [Airport code extractor](./airport-code-extractor.ipynb) +- [Extract contact information](./extract-contact-information.ipynb) +- [Micro horror story creator](./micro-horror-story-creator.ipynb) +- [Essay outline](./essay-outline.ipynb) +- [VR fitness idea generator](./vr-fitness-idea-generator.ipynb) +- [Notes to summary](./notes-to-summary.ipynb) +- [Recipe creator](./recipe-creator.ipynb) +- [Turn by turn directions](./turn-by-turn-directions.ipynb) +- [Restaurant review creator](./restaurant-review-creator.ipynb) +- [Create study notes](./create-study-notes.ipynb) +- [Interview questions](./create-interview-questions.ipynb) + +## Translation + +- [Translate programming languages](./translate-programming-languages.ipynb) +- [Translate English to other languages](./translate-english-other-languages.ipynb) +- [SQL translate](./sql-translate.ipynb) +- [SQL request](./sql-request.ipynb) + +## Additional Resources + +- [What is Azure OpenAI Service?](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/overview) +- [Azure SDK for .NET Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/openai/Azure.AI.OpenAI/tests/Samples) \ No newline at end of file diff --git a/ad-product-description.ipynb b/ad-product-description.ipynb new file mode 100644 index 0000000..54afeea --- /dev/null +++ b/ad-product-description.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Ad from product description\n", + "\n", + "Turn a product description into ad copy.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 100 |\n", + "| Temperature | 0.5 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Write a creative ad for the following product to run on Facebook aimed at parents:\n", + "\n", + "Product: Learning Room is a virtual environment to help students from kindergarten to high school excel in school.\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Write a creative ad for the following product to run on Facebook aimed at parents:\n", + "\n", + " Product: Learning Room is a virtual environment to help students from kindergarten to high school excel in school.\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=100,\n", + " Temperature=0.5f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "\r\n", + "Are you a parent who wants to give your child the best chance to succeed in school? Look no further than Learning Room! Our virtual environment is designed to help students from kindergarten to high school excel in their studies. With our interactive exercises, personalized lessons, and detailed progress tracking, your child will be well on their way to academic success. Try Learning Room today and give your child the tools they need to succeed!" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/advanced-tweet-classifier.ipynb b/advanced-tweet-classifier.ipynb new file mode 100644 index 0000000..0adf35a --- /dev/null +++ b/advanced-tweet-classifier.ipynb @@ -0,0 +1,282 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Advanced tweet classifier\n", + "\n", + "This is an advanced prompt for detecting sentiment. It allows you to provide it with a list of status updates and then provide a sentiment for each one.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Classify the sentiment in these tweets:\n", + "\n", + "1. \"I can't stand homework\"\n", + "2. \"This sucks. I'm bored 😠\"\n", + "3. \"I can't wait for Halloween!!!\"\n", + "4. \"My cat is adorable ❤️❤️\"\n", + "5. \"I hate chocolate\"\n", + "\n", + "Tweet sentiment ratings:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Classify the sentiment in these tweets:\n", + "\n", + " 1. \"I can't stand homework\"\n", + " 2. \"This sucks. I'm bored 😠\"\n", + " 3. \"I can't wait for Halloween!!!\"\n", + " 4. \"My cat is adorable ❤️❤️\"\n", + " 5. \"I hate chocolate\"\n", + "\n", + " Tweet sentiment ratings:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "1. Negative\r\n", + "2. Negative\r\n", + "3. Positive\r\n", + "4. Positive\r\n", + "5. Negative" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/airport-code-extractor.ipynb b/airport-code-extractor.ipynb new file mode 100644 index 0000000..e249f1e --- /dev/null +++ b/airport-code-extractor.ipynb @@ -0,0 +1,275 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Airport code extractor\n", + "\n", + "A simple prompt for extracting airport codes from text.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "| Stop sequence | `\\n` |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Extract the airport codes from this text:\n", + "\n", + "Text: \"I want to fly from Los Angeles to Miami.\"\n", + "Airport codes: LAX, MIA\n", + "\n", + "Text: \"I want to fly from Orlando to Boston\"\n", + "Airport codes:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Extract the airport codes from this text:\n", + "\n", + " Text: \"I want to fly from Los Angeles to Miami.\"\n", + " Airport codes: LAX, MIA\n", + "\n", + " Text: \"I want to fly from Orlando to Boston\"\n", + " Airport codes:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.StopSequences.Add(\"\\n\");\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " MCO, BOS" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/calculate-time-complexity.ipynb b/calculate-time-complexity.ipynb new file mode 100644 index 0000000..3d50fec --- /dev/null +++ b/calculate-time-complexity.ipynb @@ -0,0 +1,285 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate Time Complexity\n", + "\n", + "Find the time complexity of a function.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 64 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "int Foo(int n,int k)\n", + "{\n", + " var accum = 0;\n", + " foreach(var i in Enumerable.Range(n))\n", + " {\n", + " foreach(var l in Enumerable.Range(k))\n", + " {\n", + " accum += i\n", + " }\n", + " }\n", + " return accum;\n", + "}\n", + "// The time complexity of this function is \n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " int Foo(int n,int k)\n", + " {\n", + " var accum = 0;\n", + " foreach(var i in Enumerable.Range(n))\n", + " {\n", + " foreach(var l in Enumerable.Range(k))\n", + " {\n", + " accum += i\n", + " }\n", + " }\n", + " return accum;\n", + " }\n", + " // The time complexity of this function is \n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=64,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " O(n*k)" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/classification.ipynb b/classification.ipynb new file mode 100644 index 0000000..cbb34f4 --- /dev/null +++ b/classification.ipynb @@ -0,0 +1,277 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Classification\n", + "\n", + "Classify items into categories via example.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 64 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "The following is a list of companies and the categories they fall into:\n", + "\n", + "Apple, Facebook, Fedex\n", + "\n", + "Apple\n", + "Category:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " The following is a list of companies and the categories they fall into:\n", + "\n", + " Apple, Facebook, Fedex\n", + "\n", + " Apple\n", + " Category:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=64,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " Technology\r\n", + "\r\n", + "Facebook\r\n", + "Category: Social Media\r\n", + "\r\n", + "Fedex\r\n", + "Category: Logistics and Delivery" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/create-interview-questions.ipynb b/create-interview-questions.ipynb new file mode 100644 index 0000000..dca7e83 --- /dev/null +++ b/create-interview-questions.ipynb @@ -0,0 +1,270 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Create interview questions\n", + "\n", + "Create interview questions.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 150 |\n", + "| Temperature | 0.5 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Create a list of 8 questions for my interview with a science fiction author:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Create a list of 8 questions for my interview with a science fiction author:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=150,\n", + " Temperature=0.5f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\n", + "\n", + "1. What inspired you to write science fiction?\n", + "2. What do you think are the most important elements of a successful science fiction story?\n", + "3. How do you keep up with the latest advances in science and technology that might influence your writing?\n", + "4. What do you think are the most important themes in science fiction?\n", + "5. How has the genre of science fiction changed over the years?\n", + "6. What advice would you give to aspiring science fiction authors?\n", + "7. How do you create believable and interesting characters in your stories?\n", + "8. What have been some of the biggest challenges you have faced while writing science fiction?" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/create-study-notes.ipynb b/create-study-notes.ipynb new file mode 100644 index 0000000..2044b9f --- /dev/null +++ b/create-study-notes.ipynb @@ -0,0 +1,271 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Create study notes\n", + "\n", + "Provide a topic and get study notes.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 150 |\n", + "| Temperature | 0.3 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "What are 5 key points I should know when studying Ancient Rome?\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " What are 5 key points I should know when studying Ancient Rome?\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=150,\n", + " Temperature=0.3f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\n", + "\n", + "1. The Roman Republic: Learn about the founding of Rome and the establishment of the Roman Republic, its government, and its laws.\n", + "\n", + "2. Roman Expansion: Understand the Roman Empire's expansion and its impact on the Mediterranean world.\n", + "\n", + "3. Roman Society: Explore the social structure of Roman society, including its classes, gender roles, and religious beliefs.\n", + "\n", + "4. Roman Culture: Examine the culture of Ancient Rome, including its art, architecture, literature, and philosophy.\n", + "\n", + "5. Roman Military: Investigate the Roman military and its influence on the Roman Empire's success." + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/essay-outline.ipynb b/essay-outline.ipynb new file mode 100644 index 0000000..ea04e02 --- /dev/null +++ b/essay-outline.ipynb @@ -0,0 +1,283 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Essay outline\n", + "\n", + "Generate an outline for a research topic.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 150 |\n", + "| Temperature | 0.3 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Create an outline for an essay about Nikola Tesla and his contributions to technology:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Create an outline for an essay about Nikola Tesla and his contributions to technology:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=150,\n", + " Temperature=0.3f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\n", + "\n", + "I. Introduction\n", + "A. Definition of Nikola Tesla\n", + "B. Overview of his contributions to technology\n", + "\n", + "II. Early Life and Education\n", + "A. Tesla's childhood and education\n", + "B. Early influences on Tesla's career\n", + "\n", + "III. Tesla's Contributions to Technology\n", + "A. Alternating current\n", + "B. Radio\n", + "C. Robotics\n", + "D. X-rays\n", + "\n", + "IV. Later Years\n", + "A. Tesla's later years and death\n", + "B. Legacy of Tesla's work\n", + "\n", + "V. Conclusion\n", + "A. Summary of Tesla's life and accomplishments\n", + "B. Impact of Tesla's work on modern technology" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/extract-contact-information.ipynb b/extract-contact-information.ipynb new file mode 100644 index 0000000..70c6240 --- /dev/null +++ b/extract-contact-information.ipynb @@ -0,0 +1,286 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Extract contact information\n", + "\n", + "Extract contact information from a block of text.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 64 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Extract the name and mailing address from this email:\n", + "\n", + "Dear Kelly,\n", + "\n", + "It was great to talk to you at the seminar. I thought Jane's talk was quite good.\n", + "\n", + "Thank you for the book. Here's my address 2111 Ash Lane, Crestview CA 92002\n", + "\n", + "Best,\n", + "\n", + "Maya\n", + "\n", + "Name:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Extract the name and mailing address from this email:\n", + "\n", + " Dear Kelly,\n", + "\n", + " It was great to talk to you at the seminar. I thought Jane's talk was quite good.\n", + "\n", + " Thank you for the book. Here's my address 2111 Ash Lane, Crestview CA 92002\n", + "\n", + " Best,\n", + "\n", + " Maya\n", + "\n", + " Name:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=64,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " Maya\r\n", + "Mailing Address: 2111 Ash Lane, Crestview CA 92002" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/extract-keywords.ipynb b/extract-keywords.ipynb new file mode 100644 index 0000000..0762259 --- /dev/null +++ b/extract-keywords.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Extract Keywords\n", + "\n", + "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", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0.5 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.8 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Extract keywords from this text:\n", + "\n", + "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", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Extract keywords from this text:\n", + "\n", + " 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", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0.5f,\n", + " FrequencyPenalty=0.8f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "\r\n", + "Keywords: black-on-black ware, 20th century, 21st century, Puebloan Native American ceramic artists, Northern New Mexico, reduction-fired blackware, pueblo artists, selective burnishing/refractory slip/carving/incising designs" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/grammar-correction.ipynb b/grammar-correction.ipynb new file mode 100644 index 0000000..2ea4cd5 --- /dev/null +++ b/grammar-correction.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Grammar Correction\n", + "\n", + "Corrects sentences into standard English.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Correct this to standard English:\n", + "\n", + "She no went to the market.\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Correct this to standard English:\n", + "\n", + " She no went to the market.\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "\r\n", + "She didn't go to the market." + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/micro-horror-story-creator.ipynb b/micro-horror-story-creator.ipynb new file mode 100644 index 0000000..a96e163 --- /dev/null +++ b/micro-horror-story-creator.ipynb @@ -0,0 +1,269 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Micro horror story creator\n", + "\n", + "Creates two to three sentence short horror stories from a topic input.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0.8 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.5 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Topic: Breakfast\n", + "Two-Sentence Horror Story: He always stops crying when I pour the milk on his cereal. I just have to remember not to let him see his face on the carton.\n", + " \n", + "Topic: Wind\n", + "Two-Sentence Horror Story:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Topic: Breakfast\n", + " Two-Sentence Horror Story: He always stops crying when I pour the milk on his cereal. I just have to remember not to let him see his face on the carton.\n", + " \n", + " Topic: Wind\n", + " Two-Sentence Horror Story:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0.8f,\n", + " FrequencyPenalty=0.5f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " The wind was so loud it sounded like a thousand voices whispering. I looked around, but no one else could hear them except me." + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/movie-to-emoji.ipynb b/movie-to-emoji.ipynb new file mode 100644 index 0000000..6ac364e --- /dev/null +++ b/movie-to-emoji.ipynb @@ -0,0 +1,272 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Movie to Emoji\n", + "\n", + "Convert movie titles into emoji.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0.8 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "| Stop sequence | `\\n` |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Convert movie titles into emoji.\n", + "\n", + "Back to the Future: 👨👴🚗🕒 \n", + "Batman: 🤵🦇 \n", + "Transformers: 🚗🤖 \n", + "Star Wars:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Convert movie titles into emoji.\n", + "\n", + " Back to the Future: 👨👴🚗🕒 \n", + " Batman: 🤵🦇 \n", + " Transformers: 🚗🤖 \n", + " Star Wars:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0.8f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " ⭐️🌌" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/notes-to-summary.ipynb b/notes-to-summary.ipynb new file mode 100644 index 0000000..97db396 --- /dev/null +++ b/notes-to-summary.ipynb @@ -0,0 +1,275 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Notes to summary\n", + "\n", + "Turn meeting notes into a summary.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 64 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Convert my short hand into a first-hand account of the meeting:\n", + "\n", + "Tom: Profits up 50%\n", + "Jane: New servers are online\n", + "Kjel: Need more time to fix software\n", + "Jane: Happy to help\n", + "Parkman: Beta testing almost done\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Convert my short hand into a first-hand account of the meeting:\n", + "\n", + " Tom: Profits up 50%\n", + " Jane: New servers are online\n", + " Kjel: Need more time to fix software\n", + " Jane: Happy to help\n", + " Parkman: Beta testing almost done\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=64,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "\r\n", + "At the meeting, Tom reported that profits had increased by 50%. Jane then mentioned that the new servers were online. Kjel mentioned that they needed more time to fix the software, to which Jane responded that she was happy to help. Finally, Parkman reported that the beta testing was almost done" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/parse-unstructured-data.ipynb b/parse-unstructured-data.ipynb new file mode 100644 index 0000000..031afd9 --- /dev/null +++ b/parse-unstructured-data.ipynb @@ -0,0 +1,275 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Parse unstructured data\n", + "\n", + "Create tables from long form text by specifying a structure and supplying some examples.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 100 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "A table summarizing the fruits from Goocrux:\n", + "\n", + "There are many fruits that were found on the recently discovered planet Goocrux. There are neoskizzles that grow there, which are purple and taste like candy. There are also loheckles, which are a grayish blue fruit and are very tart, a little bit like a lemon. Pounits are a bright green color and are more savory than sweet. There are also plenty of loopnovas which are a neon pink flavor and taste like cotton candy. Finally, there are fruits called glowls, which have a very sour and bitter taste which is acidic and caustic, and a pale orange tinge to them.\n", + "\n", + "| Fruit | Color | Flavor |\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "// var endpoint = new Uri(AOAI_ENDPOINT);\n", + "// var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " A table summarizing the fruits from Goocrux:\n", + "\n", + " There are many fruits that were found on the recently discovered planet Goocrux. There are neoskizzles that grow there, which are purple and taste like candy. There are also loheckles, which are a grayish blue fruit and are very tart, a little bit like a lemon. Pounits are a bright green color and are more savory than sweet. There are also plenty of loopnovas which are a neon pink flavor and taste like cotton candy. Finally, there are fruits called glowls, which have a very sour and bitter taste which is acidic and caustic, and a pale orange tinge to them.\n", + "\n", + " | Fruit | Color | Flavor |\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=100,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "|------|-------|--------|\r\n", + "| Neoskizzles | Purple | Candy |\r\n", + "| Loheckles | Grayish Blue | Tart, like a lemon |\r\n", + "| Pounits | Bright Green | Savory |\r\n", + "| Loopnovas | Neon Pink | Cotton Candy |\r\n", + "| Glowls | Pale Orange | Sour and Bitter, acidic and caustic |" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/product-name-generator.ipynb b/product-name-generator.ipynb new file mode 100644 index 0000000..92811f9 --- /dev/null +++ b/product-name-generator.ipynb @@ -0,0 +1,272 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Product name generator\n", + "\n", + "Create product names from examples words. Influenced by a community prompt.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0.8 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Product description: A home milkshake maker\n", + "Seed words: fast, healthy, compact.\n", + "Product names: HomeShaker, Fit Shaker, QuickShake, Shake Maker\n", + "\n", + "Product description: A pair of shoes that can fit any foot size.\n", + "Seed words: adaptable, fit, omni-fit.\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Product description: A home milkshake maker\n", + " Seed words: fast, healthy, compact.\n", + " Product names: HomeShaker, Fit Shaker, QuickShake, Shake Maker\n", + "\n", + " Product description: A pair of shoes that can fit any foot size.\n", + " Seed words: adaptable, fit, omni-fit.\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0.8f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " \r\n", + "Product names: AdaptoFit, PerfectFit, OmniFoot, FlexFit." + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/qna.ipynb b/qna.ipynb new file mode 100644 index 0000000..9f466f0 --- /dev/null +++ b/qna.ipynb @@ -0,0 +1,310 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Q&A\n", + "\n", + "Answer questions based on existing knowledge.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 100 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "| Stop sequence | `\\n` |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n", + "\n", + "Q: What is human life expectancy in the United States?\n", + "A: Human life expectancy in the United States is 78 years.\n", + "\n", + "Q: Who was president of the United States in 1955?\n", + "A: Dwight D. Eisenhower was president of the United States in 1955.\n", + "\n", + "Q: Which party did he belong to?\n", + "A: He belonged to the Republican Party.\n", + "\n", + "Q: What is the square root of banana?\n", + "A: Unknown\n", + "\n", + "Q: How does a telescope work?\n", + "A: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n", + "\n", + "Q: Where were the 1992 Olympics held?\n", + "A: The 1992 Olympics were held in Barcelona, Spain.\n", + "\n", + "Q: How many squigs are in a bonk?\n", + "A: Unknown\n", + "\n", + "Q: Where is the Valley of Kings?\n", + "A:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \\\"Unknown\\\".\n", + " \n", + " Q: What is human life expectancy in the United States?\n", + " A: Human life expectancy in the United States is 78 years.\n", + " \n", + " Q: Who was president of the United States in 1955?\n", + " A: Dwight D. Eisenhower was president of the United States in 1955.\n", + " \n", + " Q: Which party did he belong to?\n", + " A: He belonged to the Republican Party.\n", + " \n", + " Q: What is the square root of banana?\n", + " A: Unknown\n", + " \n", + " Q: How does a telescope work?\n", + " A: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n", + " \n", + " Q: Where were the 1992 Olympics held?\n", + " A: The 1992 Olympics were held in Barcelona, Spain.\n", + " \n", + " Q: How many squigs are in a bonk?\n", + " A: Unknown\n", + " \n", + " Q: Where is the Valley of Kings?\n", + " A:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=100,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " The Valley of Kings is located in Luxor, Egypt." + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/recipe-creator.ipynb b/recipe-creator.ipynb new file mode 100644 index 0000000..000a0c1 --- /dev/null +++ b/recipe-creator.ipynb @@ -0,0 +1,293 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Recipe creator (eat at your own risk)\n", + "\n", + "Recipe creator (eat at your own risk)\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 120 |\n", + "| Temperature | 0.3 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Write a recipe based on these ingredients and instructions:\n", + "\n", + "Frito Pie\n", + "\n", + "Ingredients:\n", + "Fritos\n", + "Chili\n", + "Shredded cheddar cheese\n", + "Sweet white or red onions, diced small\n", + "Sour cream\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Write a recipe based on these ingredients and instructions:\n", + "\n", + " Frito Pie\n", + "\n", + " Ingredients:\n", + " Fritos\n", + " Chili\n", + " Shredded cheddar cheese\n", + " Sweet white or red onions, diced small\n", + " Sour cream\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=120,\n", + " Temperature=0.3f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "\r\n", + "Instructions:\r\n", + "\r\n", + "1. Preheat oven to 375 degrees F.\r\n", + "\r\n", + "2. Spread a layer of Fritos in the bottom of a 9x13 inch baking dish.\r\n", + "\r\n", + "3. Top the Fritos with chili and spread it evenly.\r\n", + "\r\n", + "4. Sprinkle the shredded cheddar cheese over the chili.\r\n", + "\r\n", + "5. Sprinkle the diced onions over the cheese.\r\n", + "\r\n", + "6. Bake for 15-20 minutes, or until cheese is melted and bubbly.\r\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/restaurant-review-creator.ipynb b/restaurant-review-creator.ipynb new file mode 100644 index 0000000..0e1e16a --- /dev/null +++ b/restaurant-review-creator.ipynb @@ -0,0 +1,272 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Restaurant review creator\n", + "\n", + "Turn a few words into a restaurant review.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 64 |\n", + "| Temperature | 0.5 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Write a restaurant review based on these notes:\n", + "\n", + "Name: The Blue Wharf\n", + "Lobster great, noisy, service polite, prices good.\n", + "\n", + "Review:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Write a restaurant review based on these notes:\n", + "\n", + " Name: The Blue Wharf\n", + " Lobster great, noisy, service polite, prices good.\n", + "\n", + " Review:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=64,\n", + " Temperature=0.5f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "I recently visited The Blue Wharf and was pleasantly surprised. The lobster was amazing! The prices were also very reasonable. The only downside was that it was a bit noisy, but the polite service more than made up for it. Highly recommend!" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/science-fiction-book-list-maker.ipynb b/science-fiction-book-list-maker.ipynb new file mode 100644 index 0000000..53a124c --- /dev/null +++ b/science-fiction-book-list-maker.ipynb @@ -0,0 +1,272 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Science fiction book list maker\n", + "\n", + "This makes a list of science fiction books and stops when it reaches #10.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 200 |\n", + "| Temperature | 0.5 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.52 |\n", + "| Presence penalty | 0.5 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "List 10 science fiction books:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " List 10 science fiction books:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=200,\n", + " Temperature=0.5f,\n", + " FrequencyPenalty=0.52f,\n", + " PresencePenalty=0.5f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\n", + "\n", + "1. 1984 by George Orwell\n", + "2. The War of the Worlds by H.G. Wells\n", + "3. Dune by Frank Herbert\n", + "4. Ender's Game by Orson Scott Card\n", + "5. The Hitchhiker's Guide to the Galaxy by Douglas Adams\n", + "6. Do Androids Dream of Electric Sheep? By Philip K Dick \n", + "7. I, Robot by Isaac Asimov \n", + "8. The Foundation Trilogy by Isaac Asimov \n", + "9. Brave New World by Aldous Huxley \n", + "10. Neuromancer by William Gibson" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sql-request.ipynb b/sql-request.ipynb new file mode 100644 index 0000000..9c6d0ba --- /dev/null +++ b/sql-request.ipynb @@ -0,0 +1,264 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# SQL request\n", + "\n", + "Create simple SQL queries.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Create a SQL request to find all users who live in California and have over 1000 credits:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Create a SQL request to find all users who live in California and have over 1000 credits:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0.3f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\n", + "\n", + "SELECT * FROM users\n", + "WHERE state = 'California' AND credits > 1000;" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sql-translate.ipynb b/sql-translate.ipynb new file mode 100644 index 0000000..cea84d8 --- /dev/null +++ b/sql-translate.ipynb @@ -0,0 +1,286 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# SQL translate\n", + "\n", + "Translate natural language to SQL queries.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 150 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "| Stop sequence | `#` `;` |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "### Postgres SQL tables, with their properties:\n", + "#\n", + "# Employee(id, name, department_id)\n", + "# Department(id, name, address)\n", + "# Salary_Payments(id, employee_id, amount, date)\n", + "#\n", + "### A query to list the names of the departments which employed more than 10 employees in the last 3 months\n", + "SELECT\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " ### Postgres SQL tables, with their properties:\n", + " #\n", + " # Employee(id, name, department_id)\n", + " # Department(id, name, address)\n", + " # Salary_Payments(id, employee_id, amount, date)\n", + " #\n", + " ### A query to list the names of the departments which employed more than 10 employees in the last 3 months\n", + " SELECT\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=150,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.StopSequences.Add(\"#\");\n", + "completionOptions.StopSequences.Add(\";\");\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " d.name \r\n", + "FROM Department d \r\n", + "INNER JOIN Employee e \r\n", + "ON d.id = e.department_id \r\n", + "INNER JOIN Salary_Payments sp \r\n", + "ON e.id = sp.employee_id \r\n", + "WHERE sp.date > NOW() - INTERVAL '3 months' \r\n", + "GROUP BY d.name \r\n", + "HAVING COUNT(*) > 10" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/summarize-second-grader.ipynb b/summarize-second-grader.ipynb new file mode 100644 index 0000000..678ed9c --- /dev/null +++ b/summarize-second-grader.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Summarize for a 2nd grader\n", + "\n", + "Translates difficult text into simpler concepts.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 64 |\n", + "| Temperature | 0.7 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Summarize this for a second-grade student:\n", + "\n", + "Jupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter is one of the brightest objects visible to the naked eye in the night sky, and has been known to ancient civilizations since before recorded history. It is named after the Roman god Jupiter.[19] When viewed from Earth, Jupiter can be bright enough for its reflected light to cast visible shadows,[20] and is on average the third-brightest natural object in the night sky after the Moon and Venus.\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Summarize this for a second-grade student:\n", + "\n", + " Jupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun, but two-and-a-half times that of all the other planets in the Solar System combined. Jupiter is one of the brightest objects visible to the naked eye in the night sky, and has been known to ancient civilizations since before recorded history. It is named after the Roman god Jupiter.[19] When viewed from Earth, Jupiter can be bright enough for its reflected light to cast visible shadows,[20] and is on average the third-brightest natural object in the night sky after the Moon and Venus.\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=64,\n", + " Temperature=0.7f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " \r\n", + "\r\n", + "Jupiter is the fifth planet from the Sun and it is very big. It is very bright in the night sky and has been known for a long time. It is named after the Roman god Jupiter. When we look at it from Earth, it is usually the third brightest thing in the night" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/text-to-command.ipynb b/text-to-command.ipynb new file mode 100644 index 0000000..0f0ecc0 --- /dev/null +++ b/text-to-command.ipynb @@ -0,0 +1,274 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Text to command\n", + "\n", + "Translate text into programmatic commands.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 100 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.2 |\n", + "| Presence penalty | 0.0 |\n", + "| Stop sequence | `\\n` |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Convert this text to a programmatic command:\n", + "\n", + "Example: Ask Constance if we need some bread\n", + "Output: send-msg `find constance` Do we need some bread?\n", + "\n", + "Reach out to the ski store and figure out if I can get my skis fixed before I leave on Thursday\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Convert this text to a programmatic command:\n", + "\n", + " Example: Ask Constance if we need some bread\n", + " Output: send-msg `find constance` Do we need some bread?\n", + "\n", + " Reach out to the ski store and figure out if I can get my skis fixed before I leave on Thursday\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=100,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.2f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + ".\r\n", + "\r\n", + "Output: send-msg `find ski store` Can I get my skis fixed before I leave on Thursday?" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/tldr-summarization.ipynb b/tldr-summarization.ipynb new file mode 100644 index 0000000..536a7ba --- /dev/null +++ b/tldr-summarization.ipynb @@ -0,0 +1,265 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# TL;DR summarization\n", + "\n", + "Summarize text by adding a 'tl;dr:' to the end of a text passage. It shows that the API understands how to perform a number of tasks with no instructions.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0.7 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 1.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei.\n", + "\n", + "Tl;dr\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei.\n", + "\n", + " Tl;dr\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0.7f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=1.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + ": Neutron stars are the smallest and densest stellar objects, with a radius of 10 kilometres and mass of 1.4 solar masses. They are created when a massive star undergoes a supernova explosion, which causes gravitational collapse and compresses the core past white dwarf star density." + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/translate-english-other-languages.ipynb b/translate-english-other-languages.ipynb new file mode 100644 index 0000000..e11f555 --- /dev/null +++ b/translate-english-other-languages.ipynb @@ -0,0 +1,271 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Translate English to other languages\n", + "\n", + "Translates English text into French, Spanish and Japanese.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 100 |\n", + "| Temperature | 0.3 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Translate this into 1. French, 2. Spanish and 3. Japanese:\n", + "\n", + "What rooms do you have available?\n", + "\n", + "1.\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Translate this into 1. French, 2. Spanish and 3. Japanese:\n", + "\n", + " What rooms do you have available?\n", + "\n", + " 1.\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " Quels sont les chambres que vous avez disponibles ?\r\n", + "2. ¿Qué habitaciones tienes disponibles?\r\n", + "3. どの部屋が利用可能ですか" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/translate-programming-languages.ipynb b/translate-programming-languages.ipynb new file mode 100644 index 0000000..019ebc5 --- /dev/null +++ b/translate-programming-languages.ipynb @@ -0,0 +1,286 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Translate programming languages\n", + "\n", + "To translate from one programming language to another we can use the comments to specify the source and target languages.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 150 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "| Stop sequence | `###` |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "##### Translate this function from Python into C#\n", + "### Python\n", + " \n", + " def predict_proba(X: Iterable[str]):\n", + " return np.array([predict_one_probas(tweet) for tweet in X])\n", + " \n", + "### C#\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " ##### Translate this function from Python into C#\n", + " ### Python\n", + " \n", + " def predict_proba(X: Iterable[str]):\n", + " return np.array([predict_one_probas(tweet) for tweet in X])\n", + " \n", + " ### C#\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=150,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "\r\n", + "public double[] PredictProba(IEnumerable X)\r\n", + "{\r\n", + " double[] result = new double[X.Count()];\r\n", + " int i = 0;\r\n", + " foreach (string tweet in X)\r\n", + " {\r\n", + " result[i] = PredictOneProbas(tweet);\r\n", + " i++;\r\n", + " }\r\n", + " return result;\r\n", + "}" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/turn-by-turn-directions.ipynb b/turn-by-turn-directions.ipynb new file mode 100644 index 0000000..13d96c7 --- /dev/null +++ b/turn-by-turn-directions.ipynb @@ -0,0 +1,270 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Turn by turn directions\n", + "\n", + "Convert natural language to turn-by-turn directions.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 64 |\n", + "| Temperature | 0.3 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.0 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Create a numbered list of turn-by-turn directions from this text: \n", + "\n", + "Go south on 95 until you hit Sunrise boulevard then take it east to us 1 and head south. Tom Jenkins bbq will be on the left after several miles.\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
  • Azure.AI.OpenAI, 1.0.0-beta.5
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Create a numbered list of turn-by-turn directions from this text: \n", + "\n", + " Go south on 95 until you hit Sunrise boulevard then take it east to us 1 and head south. Tom Jenkins bbq will be on the left after several miles.\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=64,\n", + " Temperature=0.3f,\n", + " FrequencyPenalty=0.0f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\r\n", + "\r\n", + "1. Go south on 95 \r\n", + "2. Take Sunrise Boulevard east \r\n", + "3. Head south on US 1 \r\n", + "4. Tom Jenkins BBQ will be on the left after several miles" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/tweet-classifier.ipynb b/tweet-classifier.ipynb new file mode 100644 index 0000000..1609f29 --- /dev/null +++ b/tweet-classifier.ipynb @@ -0,0 +1,267 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Tweet classifier\n", + "\n", + "This is a basic prompt for detecting sentiment.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 60 |\n", + "| Temperature | 0 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 0.5 |\n", + "| Presence penalty | 0.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Decide whether a Tweet's sentiment is positive, neutral, or negative.\n", + "\n", + "Tweet: \"I loved the new Batman movie!\"\n", + "Sentiment:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
  • Azure.AI.OpenAI, 1.0.0-beta.5
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Decide whether a Tweet's sentiment is positive, neutral, or negative.\n", + "\n", + " Tweet: \"I loved the new Batman movie!\"\n", + " Sentiment:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=60,\n", + " Temperature=0f,\n", + " FrequencyPenalty=0.5f,\n", + " PresencePenalty=0.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + " Positive" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/vr-fitness-idea-generator.ipynb b/vr-fitness-idea-generator.ipynb new file mode 100644 index 0000000..671f15d --- /dev/null +++ b/vr-fitness-idea-generator.ipynb @@ -0,0 +1,269 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# VR fitness idea generator\n", + "\n", + "Create ideas for fitness and virtual reality games.\n", + "\n", + "## Settings\n", + "\n", + "| Setting | Value |\n", + "| --- | --- |\n", + "| Model | text-davinci-003 |\n", + "| Max tokens | 150 |\n", + "| Temperature | 0.6 | \n", + "| Top p | 1 | \n", + "| Frequency penalty | 1.0 |\n", + "| Presence penalty | 1.0 |\n", + "\n", + "## Prompt\n", + "\n", + "```text\n", + "Brainstorm some ideas combining VR and fitness:\n", + "```" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install Azure OpenAI Service .NET SDK\n", + "\n", + "[Azure.AI.OpenAI NuGet package](https://www.nuget.org/packages/Azure.AI.OpenAI/)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
Installed Packages
  • Azure.AI.OpenAI, 1.0.0-beta.5
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.5\"" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "using System;\n", + "using Azure.AI.OpenAI;" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure Azure OpenAI client" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var AOAI_ENDPOINT = Environment.GetEnvironmentVariable(\"AOAI_ENDPOINT\");\n", + "var AOAI_KEY = Environment.GetEnvironmentVariable(\"AOAI_KEY\");\n", + "var AOAI_DEPLOYMENTID = Environment.GetEnvironmentVariable(\"AOAI_DEPLOYMENTID\");" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var endpoint = new Uri(AOAI_ENDPOINT);\n", + "var credentials = new Azure.AzureKeyCredential(AOAI_KEY);\n", + "var openAIClient = new OpenAIClient(endpoint, credentials);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Define prompt" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var prompt = \n", + " \"\"\"\n", + " Brainstorm some ideas combining VR and fitness:\n", + " \"\"\";" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Configure completion options" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "var completionOptions = new CompletionsOptions\n", + "{\n", + " MaxTokens=150,\n", + " Temperature=0.6f,\n", + " FrequencyPenalty=1.0f,\n", + " PresencePenalty=1.0f,\n", + "};\n", + "\n", + "completionOptions.Prompts.Add(prompt);" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Generate completions" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [], + "source": [ + "Completions response = await openAIClient.GetCompletionsAsync(AOAI_DEPLOYMENTID,completionOptions);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "dotnet_interactive": { + "language": "csharp" + }, + "polyglot_notebook": { + "kernelName": "csharp" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\n", + "\n", + "1. Virtual Reality Workout Games - Players can use a VR headset to immerse themselves in interactive, high-intensity workouts that provide an engaging and fun way to exercise.\n", + "\n", + "2. VR Fitness Classes - Attendees can put on their headsets and join virtual fitness classes taught by real instructors who will guide them through the workout while providing motivation and instruction. \n", + "\n", + "3. VR Gym Machines - Traditional gym equipment is upgraded with virtual reality technology so that users can experience more immersive and realistic workouts from home or at the gym. \n", + "\n", + "4. Virtual Personal Trainers - Hire a personal trainer virtually via your headset, who will create custom tailored workouts for you based on your goals, skill level, and interests while giving" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "response.Choices[0].Text" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".NET (C#)", + "language": "C#", + "name": ".net-csharp" + }, + "language_info": { + "name": "polyglot-notebook" + }, + "polyglot_notebook": { + "kernelInfo": { + "defaultKernelName": "csharp", + "items": [ + { + "aliases": [], + "languageName": "csharp", + "name": "csharp" + } + ] + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}