Creating custom functions
1. Without Parameters Schema
// Creating functionCall without parameters schema
var functionCall = FunctionCall.Create("MyFunction", "This is a sample function", new MyFunctionDelegate());2. With Parameters Schema
using Glitch9.IO.Json.Schema;
// Define your custom return class with JsonSchemaAttributes.
public class GetCurrentTemperatureArgument
{
// Example string property: Define properties according to the expected API response structure.
[JsonSchema("location", Description = "The city and state, e.g., San Francisco, CA.", required: true)]
public string Location { get; set; }
// Example enum property: If your response includes fields that can be categorized into enums,
// define an enum and use it as the type for such properties.
[JsonSchema("unit", Description = "The temperature unit to use. Infer this from the user's location.", required: false)]
public TemperatureUnit Unit { get; set; }
// Properties without JsonSchemaAttribute won't be included in Parameters Schema.
[JsonProperty("temperature")]
public string Temperature { get; set; }
}
// Example enum to represent a category or type of response.
// "enum": ["Celsius", "Fahrenheit"],
public enum TemperatureUnit
{
Celsius,
Fahrenheit
}3. Extending the Function Delegate
Last updated