-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugins.cs
59 lines (49 loc) · 1.55 KB
/
Plugins.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Microsoft.SemanticKernel;
using System.ComponentModel;
namespace OllamaSample
{
/// <summary>
/// Simple plugin that just returns the time.
/// </summary>
public class MyTimePlugin
{
[KernelFunction, Description("Get the current time")]
public DateTimeOffset Time() => DateTimeOffset.Now;
}
/// <summary>
/// Class that represents a controllable light bulb.
/// </summary>
[Description("Represents a light bulb")]
public class MyLightPlugin(bool turnedOn = false)
{
private bool _turnedOn = turnedOn;
[KernelFunction, Description("Returns whether this light is on")]
public bool IsTurnedOn() => _turnedOn;
[KernelFunction, Description("Turn on this light")]
public void TurnOn() => _turnedOn = true;
[KernelFunction, Description("Turn off this light")]
public void TurnOff() => _turnedOn = false;
}
/// <summary>
/// Class that represents a controllable alarm.
/// </summary>
public class MyAlarmPlugin
{
private string _hour;
public MyAlarmPlugin(string providedHour)
{
this._hour = providedHour;
}
[KernelFunction, Description("Sets an alarm at the provided time")]
public string SetAlarm(string time)
{
this._hour = time;
return GetCurrentAlarm();
}
[KernelFunction, Description("Get current alarm set")]
public string GetCurrentAlarm()
{
return $"Alarm set for {_hour}";
}
}
}