microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
devtools-port-no-auth

Branches

Tags

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

Clone

HTTPS

Download ZIP

Samples/Samples.AI/Prompts/WeatherPrompt.cs

47lines · modeblame

19e4df96Aamir Jawaid8 months ago1using 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")]
14public string GetUserLocation()
15{
16var locations = new[] { "Seattle", "San Francisco", "New York" };
17var random = new Random();
18var location = locations[random.Next(locations.Length)];
19
20context.Log.Info($"[PROMPT-FUNCTION] get_user_location called, returning mock location: '{location}'");
21return location;
22}
23
24[Function]
25[Function.Description("Search for weather at a specific location")]
26public string WeatherSearch([Param] string location)
27{
28context.Log.Info($"[PROMPT-FUNCTION] weather_search called with location='{location}'");
29
30var 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
37if (!weatherByLocation.TryGetValue(location, out var weather))
38{
39context.Log.Info($"[PROMPT-FUNCTION] Weather data not found for location '{location}'");
40return "Sorry, I could not find the weather for that location";
41}
42
43var result = $"The weather in {location} is {weather.Condition} with a temperature of {weather.Temperature}°F";
44context.Log.Info($"[PROMPT-FUNCTION] Returning weather data: {result}");
45return result;
46}
b6c66549Alex Acebo6 months ago47}