microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/sub-pr-188-again

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Samples/Samples.AI/Prompts/WeatherPrompt.cs

47lines · modecode

1using Microsoft.Teams.AI.Annotations;
2using Microsoft.Teams.Api.Activities;
3using Microsoft.Teams.Apps;
4
5namespace Samples.AI.Prompts;
6
7[Prompt]
8[Prompt.Description("Weather assistant")]
9[Prompt.Instructions("You are a helpful assistant that can help the user get the weather. First get their location, then get the weather for that location.")]
10public class WeatherPrompt(IContext<IActivity> context)
11{
12 [Function]
13 [Function.Description("Gets the location of the user")]
14 public string GetUserLocation()
15 {
16 var locations = new[] { "Seattle", "San Francisco", "New York" };
17 var random = new Random();
18 var location = locations[random.Next(locations.Length)];
19
20 context.Log.Info($"[PROMPT-FUNCTION] get_user_location called, returning mock location: '{location}'");
21 return location;
22 }
23
24 [Function]
25 [Function.Description("Search for weather at a specific location")]
26 public string WeatherSearch([Param] string location)
27 {
28 context.Log.Info($"[PROMPT-FUNCTION] weather_search called with location='{location}'");
29
30 var weatherByLocation = new Dictionary<string, (int Temperature, string Condition)>
31 {
32 ["Seattle"] = (65, "sunny"),
33 ["San Francisco"] = (60, "foggy"),
34 ["New York"] = (75, "rainy")
35 };
36
37 if (!weatherByLocation.TryGetValue(location, out var weather))
38 {
39 context.Log.Info($"[PROMPT-FUNCTION] Weather data not found for location '{location}'");
40 return "Sorry, I could not find the weather for that location";
41 }
42
43 var result = $"The weather in {location} is {weather.Condition} with a temperature of {weather.Temperature}°F";
44 context.Log.Info($"[PROMPT-FUNCTION] Returning weather data: {result}");
45 return result;
46 }
47}