Skip to content

Commit

Permalink
helper-getname with scenarios (#130)
Browse files Browse the repository at this point in the history
* helper-getname with scenarios

* revamped how resource names <-- --> filenames work in file_helpers; added cool helper function scenarios to ideas

* `--instructions` now works with `ai dev new ...`

* now can call void methods
  • Loading branch information
robch authored Dec 5, 2023
1 parent 4586eab commit 8e8d1fa
Show file tree
Hide file tree
Showing 24 changed files with 427 additions and 14 deletions.
10 changes: 10 additions & 0 deletions ideas/cool-helper-function-scenarios/HelperFunctionClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Azure.AI.Details.Common.CLI.Extensions.HelperFunctions;

public static class HelperFunctionClass
{
[HelperFunctionDescription("Gets the user's name")]
public static string GetUsersName()
{
return Environment.UserName;
}
}
24 changes: 24 additions & 0 deletions ideas/cool-helper-function-scenarios/HelperFunctionsProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableDefaultCompileItems>true</EnableDefaultCompileItems>
<AICLIExtensionReferencePath Condition="'$(AICLIExtensionReferencePath)' == ''">D:\src\ai-cli\src\ai\bin\Debug\net7.0</AICLIExtensionReferencePath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.36.0" />
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Azure.AI.OpenAI" Version="1.0.0-beta.9" />
</ItemGroup>

<ItemGroup>
<Reference Include="Azure.AI.CLI.Extensions.HelperFunctions">
<HintPath>$(AICLIExtensionReferencePath)\Azure.AI.CLI.Extensions.HelperFunctions.dll</HintPath>
</Reference>
</ItemGroup>

</Project>
39 changes: 39 additions & 0 deletions ideas/cool-helper-function-scenarios/NutritionHelperFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Azure.AI.Details.Common.CLI.Extensions.HelperFunctions;

public static class NutritionHelperFunctions
{
private const string AppId = "3edd9fa9";
private const string AppKey = "ff12a3b0bbe5612e3084948de888bb47";

// var request = require('request');
// var options = {
// 'method': 'GET',
// 'url': 'https://trackapi.nutritionix.com/v2/search/instant/?query=hamburger',
// 'headers': {
// 'Content-Type': 'application/json',
// 'x-app-id': ,
// 'x-app-key':
// }
// };
// request(options, function (error, response) {
// if (error) throw new Error(error);
// console.log(response.body);
// });

// {"common":[{"food_name":"cheeseburger","serving_unit":"item","tag_name":"cheeseburger","serving_qty":1,"common_type":null,"tag_id":"445","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/445_thumb.jpg"},"locale":"en_US"},{"food_name":"cheeseburgers","serving_unit":"item","tag_name":"cheeseburger","serving_qty":1,"common_type":null,"tag_id":"445","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/445_thumb.jpg"},"locale":"en_US"},{"food_name":"cheeseburger mac","serving_unit":"cup","tag_name":"cheeseburger macaroni","serving_qty":1,"common_type":null,"tag_id":"8385","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/8385_thumb.jpg"},"locale":"en_US"},{"food_name":"bacon cheeseburger","serving_unit":"item","tag_name":"bacon cheeseburger","serving_qty":1,"common_type":null,"tag_id":"1806","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/1806_thumb.jpg"},"locale":"en_US"},{"food_name":"chili cheeseburger","serving_unit":"burger","tag_name":"chili burger","serving_qty":1,"common_type":null,"tag_id":"5856","photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"locale":"en_US"},{"food_name":"cheeseburger no bun","serving_unit":"patty with cheese","tag_name":"cheeseburger without bun","serving_qty":1,"common_type":null,"tag_id":"8568","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/8568_thumb.jpg"},"locale":"en_US"},{"food_name":"double cheeseburger","serving_unit":"item","tag_name":"double cheeseburger","serving_qty":1,"common_type":null,"tag_id":"3428","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/3428_thumb.jpg"},"locale":"en_US"},{"food_name":"turkey cheeseburger","serving_unit":"burger on bun","tag_name":"turkey burger","serving_qty":1,"common_type":null,"tag_id":"1416","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/1416_thumb.jpg"},"locale":"en_US"},{"food_name":"cheeseburger slider","serving_unit":"slider","tag_name":"cheeseburger slider","serving_qty":1,"common_type":null,"tag_id":"3645","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/3645_thumb.jpg"},"locale":"en_US"},{"food_name":"bunless cheeseburger","serving_unit":"patty with cheese","tag_name":"cheeseburger without bun","serving_qty":1,"common_type":null,"tag_id":"8568","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/8568_thumb.jpg"},"locale":"en_US"},{"food_name":"cheeseburger macaroni","serving_unit":"cup","tag_name":"cheeseburger macaroni","serving_qty":1,"common_type":null,"tag_id":"8385","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/8385_thumb.jpg"},"locale":"en_US"},{"food_name":"jalapeno cheeseburger","serving_unit":"burger","tag_name":"jalapeno cheeseburger","serving_qty":1,"common_type":null,"tag_id":"13199","photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"locale":"en_US"},{"food_name":"cheeseburger casserole","serving_unit":"cup","tag_name":"cheeseburger casserole","serving_qty":1,"common_type":null,"tag_id":"6206","photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"locale":"en_US"},{"food_name":"cheeseburger and fries","serving_unit":"meal","tag_name":"burger and fries","serving_qty":1,"common_type":null,"tag_id":"13312","photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"locale":"en_US"},{"food_name":"bacon cheeseburger no bun","serving_unit":"burger without bun","tag_name":"bacon cheeseburger without bun","serving_qty":1,"common_type":null,"tag_id":"9936","photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"locale":"en_US"},{"food_name":"bacon and blue cheeseburger","serving_unit":"burger","tag_name":"bacon and blue cheese burger","serving_qty":1,"common_type":null,"tag_id":"2939","photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"locale":"en_US"},{"food_name":"grilled cheese cheeseburger","serving_unit":"burger","tag_name":"grilled cheese burger","serving_qty":1,"common_type":null,"tag_id":"5901","photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"locale":"en_US"},{"food_name":"hamburger helper cheeseburger","serving_unit":"cup","tag_name":"hamburger helper","serving_qty":1,"common_type":2,"tag_id":"5226","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/5226_thumb.jpg"},"locale":"en_US"},{"food_name":"hamburger helper cheeseburger macaroni","serving_unit":"cup","tag_name":"hamburger helper","serving_qty":1,"common_type":2,"tag_id":"5226","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/5226_thumb.jpg"},"locale":"en_US"},{"food_name":"cheeseburger macaroni hamburger helper","serving_unit":"cup","tag_name":"hamburger helper","serving_qty":1,"common_type":2,"tag_id":"5226","photo":{"thumb":"https://nix-tag-images.s3.amazonaws.com/5226_thumb.jpg"},"locale":"en_US"}],"branded":[{"food_name":"Cheeseburger","serving_unit":"Serving","nix_brand_id":"521b95474a56d006cae2a12c","brand_name_item_name":"Burgermaster Cheeseburger","serving_qty":1,"nf_calories":780,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Burgermaster","region":1,"brand_type":1,"nix_item_id":"53444fb57ba4ca15456f6069","locale":"en_US"},{"food_name":"Angus Cheeseburger","serving_unit":"sandwich","nix_brand_id":"58b12c06ef3729173e32d724","brand_name_item_name":"Sam's Angus Cheeseburger","serving_qty":1,"nf_calories":510,"photo":{"thumb":"https://nutritionix-api.s3.amazonaws.com/64f468a4cc7b7d000997e89a.jpeg"},"brand_name":"Sam's","region":1,"brand_type":2,"nix_item_id":"64f468a3cc7b7d000997e899","locale":"en_US"},{"food_name":"Bacon Cheeseburger","serving_unit":"serving","nix_brand_id":"62101eae4c99436e6de8b6a0","brand_name_item_name":"Speedway Bacon Cheeseburger","serving_qty":1,"nf_calories":480,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Speedway","region":1,"brand_type":1,"nix_item_id":"d3ea921306d0d564a39af1de","locale":"en_US"},{"food_name":"Double Cheeseburger","serving_unit":"Serving","nix_brand_id":"513fbc1283aa2dc80c0001fa","brand_name_item_name":"Wienerschnitzel Double Cheeseburger","serving_qty":1,"nf_calories":760,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Wienerschnitzel","region":1,"brand_type":1,"nix_item_id":"5266a26d9f05a39eb301139b","locale":"en_US"},{"food_name":"Jr. Cheeseburger","serving_unit":"oz","nix_brand_id":"513fbc1283aa2dc80c000017","brand_name_item_name":"Denny's Jr. Cheeseburger","serving_qty":6,"nf_calories":470,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Denny's","region":1,"brand_type":1,"nix_item_id":"d3ea7274065e4ea4cca817bb","locale":"en_US"},{"food_name":"Kids Cheeseburger","serving_unit":"Order","nix_brand_id":"634efbe93d5e74d566b53b8a","brand_name_item_name":"Jaggers Kids Cheeseburger","serving_qty":1,"nf_calories":490,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Jaggers","region":1,"brand_type":1,"nix_item_id":"bd9d2815e2f3201746ea11a1","locale":"en_US"},{"food_name":"Single Cheeseburger","serving_unit":"oz","nix_brand_id":"513fbc1283aa2dc80c000017","brand_name_item_name":"Denny's Single Cheeseburger","serving_qty":12,"nf_calories":590,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Denny's","region":1,"brand_type":1,"nix_item_id":"513fc992927da70408000ef3","locale":"en_US"},{"food_name":"BurgerFi Cheeseburger","serving_unit":"Serving","nix_brand_id":"513fbc1283aa2dc80c000316","brand_name_item_name":"BurgerFi BurgerFi Cheeseburger","serving_qty":1,"nf_calories":800,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"BurgerFi","region":1,"brand_type":1,"nix_item_id":"516d9a40e3afed032c7daae7","locale":"en_US"},{"food_name":"Cheeseburger Sliders","serving_unit":"Serving","nix_brand_id":"513fbc1283aa2dc80c000149","brand_name_item_name":"Friendly's Cheeseburger Sliders","serving_qty":1,"nf_calories":700,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Friendly's","region":1,"brand_type":1,"nix_item_id":"ddee1196081b55f0ff35f37f","locale":"en_US"},{"food_name":"Executive Cheeseburger","serving_unit":"serving","nix_brand_id":"513fbc1283aa2dc80c0012c8","brand_name_item_name":"Eggspectation Executive Cheeseburger","serving_qty":1,"nf_calories":1430,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Eggspectation","region":1,"brand_type":1,"nix_item_id":"513fc9cd673c4fbc26007142","locale":"en_US"},{"food_name":"Impossible Cheeseburger","serving_unit":"Serving","nix_brand_id":"513fbc1283aa2dc80c000015","brand_name_item_name":"Applebee's Impossible Cheeseburger","serving_qty":1,"nf_calories":1050,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Applebee's","region":1,"brand_type":1,"nix_item_id":"d3ea84131ad59c44c4859b67","locale":"en_US"},{"food_name":"Mooyah Cheeseburger","serving_unit":"oz","nix_brand_id":"513fbc1283aa2dc80c000153","brand_name_item_name":"Mooyah Mooyah Cheeseburger","serving_qty":9.600000381469727,"nf_calories":700,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Mooyah","region":1,"brand_type":1,"nix_item_id":"d3ea7274665a7cedb19ffd82","locale":"en_US"},{"food_name":"Classic Cheeseburger","serving_unit":"Serving","nix_brand_id":"513fbc1283aa2dc80c000015","brand_name_item_name":"Applebee's Classic Cheeseburger","serving_qty":1,"nf_calories":1220,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Applebee's","region":1,"brand_type":1,"nix_item_id":"15218126467a018dccc535d7","locale":"en_US"},{"food_name":"Original Cheeseburger","serving_unit":"burger","nix_brand_id":"513fbc1283aa2dc80c00011b","brand_name_item_name":"Burgerville Original Cheeseburger","serving_qty":1,"nf_calories":400,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Burgerville","region":1,"brand_type":1,"nix_item_id":"23cb88164478ee89c3065a6b","locale":"en_US"},{"food_name":"Piquant Cheeseburger","serving_unit":"Burger","nix_brand_id":"513fbc1283aa2dc80c00011b","brand_name_item_name":"Burgerville Piquant Cheeseburger","serving_qty":1,"nf_calories":530,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Burgerville","region":1,"brand_type":1,"nix_item_id":"bd9d1614ac37c3528f130b86","locale":"en_US"},{"food_name":"Brioche Cheeseburger","serving_unit":"Serving","nix_brand_id":"513fbc1283aa2dc80c00025f","brand_name_item_name":"Mimi's Cafe Brioche Cheeseburger","serving_qty":1,"nf_calories":780,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Mimi's Cafe","region":1,"brand_type":1,"nix_item_id":"529e7fc7f9655f6d3500b6a7","locale":"en_US"},{"food_name":"Burger Cheeseburger Soup","serving_unit":"oz","nix_brand_id":"513fbc1283aa2dc80c000221","brand_name_item_name":"Zoup! Burger Cheeseburger Soup","serving_qty":8,"nf_calories":300,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Zoup!","region":1,"brand_type":1,"nix_item_id":"bd9d0016232b073ce21ab21f","locale":"en_US"},{"food_name":"Cheeseburger Stuffer","serving_unit":"Sandwich","nix_brand_id":"c64042820a1eef88d2068f9f","brand_name_item_name":"Duchess Shoppe Cheeseburger Stuffer","serving_qty":1,"nf_calories":370,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Duchess Shoppe","region":1,"brand_type":1,"nix_item_id":"32f1214223d2e1002d7f66c0","locale":"en_US"},{"food_name":"Del Cheeseburger","serving_unit":"g","nix_brand_id":"513fbc1283aa2dc80c0000b4","brand_name_item_name":"Del Taco Del Cheeseburger","serving_qty":191,"nf_calories":470,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Del Taco","region":1,"brand_type":1,"nix_item_id":"521b95cd4a56d006d578beb9","locale":"en_US"},{"food_name":"Kids Cheeseburger Slider","serving_unit":"Serving","nix_brand_id":"513fbc1283aa2dc80c000149","brand_name_item_name":"Friendly's Kids Cheeseburger Slider","serving_qty":1,"nf_calories":230,"photo":{"thumb":"https://d2eawub7utcl6.cloudfront.net/images/nix-apple-grey.png","highres":null,"is_user_uploaded":false},"brand_name":"Friendly's","region":1,"brand_type":1,"nix_item_id":"c640685039bf6090eb8fce83","locale":"en_US"}]}

[HelperFunctionDescription("Gets nutrition data for a food item")]
public static async Task<string> GetNutritionDataForFoodItem(string foodItem)
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-app-id", AppId);
client.DefaultRequestHeaders.Add("x-app-key", AppKey);
var response = await client.GetAsync($"https://trackapi.nutritionix.com/v2/search/instant/?query={foodItem}&detailed=false");
var content = await response.Content.ReadAsStringAsync();
return content;
}
}
31 changes: 31 additions & 0 deletions ideas/cool-helper-function-scenarios/PokemonHelperFunctions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Azure.AI.Details.Common.CLI.Extensions.HelperFunctions;

public static class PokemonHelperFunctions
{
private static readonly HttpClient client = new HttpClient();

[HelperFunctionDescription("Get information of a pokemon")]
public static async Task<string> GetPokemonInfo(string pokemonName)
{
var responseString = await client.GetStringAsync($"https://pokeapi.co/api/v2/pokemon/{pokemonName}");
return responseString;
}

[HelperFunctionDescription("Get abilities of a pokemon")]
public static async Task<List<string>> GetPokemonAbilities(string pokemonName)
{
var responseString = await client.GetStringAsync($"https://pokeapi.co/api/v2/pokemon/{pokemonName}");
dynamic responseObj = JsonConvert.DeserializeObject(responseString);
List<string> abilities = new List<string>();
foreach (var ability in responseObj.abilities)
{
abilities.Add(Convert.ToString(ability.ability.name));
}
return abilities;
}
}
13 changes: 13 additions & 0 deletions ideas/cool-helper-function-scenarios/QRCodeHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Azure.AI.Details.Common.CLI.Extensions.HelperFunctions;

public static class QRCodeHelper
{
[HelperFunctionDescription("Generates a QR code URL")]
public static string GenerateQRCodeUrl(string url, bool isTransparent, int size, string format)
{
string transparencyOption = isTransparent ? "_transparent" : "";
string sizeOption = size > 1 ? $"_{size}" : "";

return $"https://qrtag.net/api/qr{transparencyOption}{sizeOption}.{format}?url={url}";
}
}
22 changes: 22 additions & 0 deletions ideas/cool-helper-function-scenarios/WolframAlphaHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Azure.AI.Details.Common.CLI.Extensions.HelperFunctions;
using System;
using System.Net.Http;
using System.Threading.Tasks;

public static class WolframAlphaHelper
{
private static readonly HttpClient client = new HttpClient();

[HelperFunctionDescription("Calls Wolfram Alpha to answer a calculus question")]
public static async Task<string> AnswerCalculusQuestion(string question)
{
string wolframAlphaApiKey = "JJVEU8-J2TE2U24G2";
string requestUri = $"http://api.wolframalpha.com/v2/query?input={Uri.EscapeDataString(question)}&appid={wolframAlphaApiKey}";

HttpResponseMessage response = await client.GetAsync(requestUri);
response.EnsureSuccessStatusCode();

string responseBody = await response.Content.ReadAsStringAsync();
return responseBody;
}
}
7 changes: 7 additions & 0 deletions ideas/cool-helper-function-scenarios/prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{scenario}

Task you must perform:
1. Please create a new class with these helper functions. Do it now.
2. Please update the csproj file to include any new references required. Do it now.

Don't show me the code, just create the files. Do it now.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Create a new class with helper functions that use Octokit to interact with GitHub issues.

I want helper functions for these scenarios:
- Listing open issues, just the ID and title as a string.
- Finding issues that contain specified text in the title or body, returning the ID and title as a string.
- Listing comments on an issue, just the ID, author, and body as a string.
- Comment on an issue by ID, with a specified comment, returning the ID of the comment.
1 change: 1 addition & 0 deletions ideas/cool-helper-function-scenarios/scenario-pokeapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make a helper function class with methods that use the pokeapi (https://pokeapi.co/api/v2/) to answer pokemon questions
Loading

0 comments on commit 8e8d1fa

Please sign in to comment.