microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Samples/Samples.Lights/LightsPrompt.cs
44lines · modecode
| 1 | using Microsoft.Teams.AI.Annotations; |
| 2 | using Microsoft.Teams.Api.Activities; |
| 3 | using Microsoft.Teams.Apps; |
| 4 | |
| 5 | namespace Samples.Lights; |
| 6 | |
| 7 | [Prompt] |
| 8 | [Prompt.Description("manage light status")] |
| 9 | [Prompt.Instructions( |
| 10 | "The following is a conversation with an AI assistant.", |
| 11 | "The assistant can turn the lights on or off.", |
| 12 | "The lights are currently off." |
| 13 | )] |
| 14 | public class LightsPrompt(IContext.Accessor accessor) |
| 15 | { |
| 16 | private IContext<IActivity> context => accessor.Value!; |
| 17 | |
| 18 | [Function] |
| 19 | [Function.Description("get the current light status")] |
| 20 | public bool GetLightStatus() |
| 21 | { |
| 22 | return State.From(context).Status; |
| 23 | } |
| 24 | |
| 25 | [Function] |
| 26 | [Function.Description("turn the lights on")] |
| 27 | public string LightsOn() |
| 28 | { |
| 29 | var state = State.From(context); |
| 30 | state.Status = true; |
| 31 | state.Save(context); |
| 32 | return "the lights are now on"; |
| 33 | } |
| 34 | |
| 35 | [Function] |
| 36 | [Function.Description("turn the lights off")] |
| 37 | public string LightsOff() |
| 38 | { |
| 39 | var state = State.From(context); |
| 40 | state.Status = false; |
| 41 | state.Save(context); |
| 42 | return "the lights are now off"; |
| 43 | } |
| 44 | } |