-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWeatherPlugin.cs
More file actions
25 lines (24 loc) · 906 Bytes
/
WeatherPlugin.cs
File metadata and controls
25 lines (24 loc) · 906 Bytes
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
using Microsoft.SemanticKernel;
using System.ComponentModel;
namespace DXBlazorChatFunctionCalling.Semantic.Services {
public class WeatherPlugin {
[KernelFunction]
[Description("Gets the current weather in the city")]
public static string GetWeather([Description("The name of the city")] string city) {
switch(city) {
case "Los Angeles":
case "LA":
return GetTemperatureValue(20);
case "London":
return GetTemperatureValue(15);
default:
return $"The information about the weather in {city} is not available.";
}
}
static string GetTemperatureValue(int value)
{
var valueInFahrenheits = value * 9 / 5 + 32;
return $"{valueInFahrenheits}\u00b0F ({value}\u00b0C)";
}
}
}