Add functions like below in Start().
In this example, GetWeatherAsync will be invoked when weather is detected as function by ChatGPT. See also ChatGPTStreamSkill.Start().
// Define function
var weatherFunction = new ChatGPTFunction("weather", "指定された地点の天気予報を調べます", functions.GetWeatherAsync);
// Add properties to function
weatherFunction.AddProperty("location", new Dictionary<string, object>()
{
{ "type", "string" }
});
// Register function
ChatGPTFunctions.Add(weatherFunction);
And, here is the example of implementation of function. See also ExampleFunctions.cs.
public async UniTask<string> DoSomethingAsync(string jsonString, CancellationToken token)
{
// Parse arguments
var funcArgs = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonString);
// Do something
// This message will be sent to ChatGPT again to convert human-friendly response
return "Do something: success";
}
Add functions like below in
Start()
. In this example,GetWeatherAsync
will be invoked whenweather
is detected as function by ChatGPT. See alsoChatGPTStreamSkill.Start()
.And, here is the example of implementation of function. See also ExampleFunctions.cs.