Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created April 13, 2026 15:16
Show Gist options
  • Select an option

  • Save wullemsb/3977eec6094337e649aba21341067c92 to your computer and use it in GitHub Desktop.

Select an option

Save wullemsb/3977eec6094337e649aba21341067c92 to your computer and use it in GitHub Desktop.
// Define tool functions
static string GetWeather(string city) => $"Weather in {city}: 18°C, partly cloudy."; // Replace with real API call
static string GetForecast(string city, int days) => $"{days}-day forecast for {city}: mostly sunny with occasional showers.";
// Create tool descriptors
var weatherTools = new[]
{
AIFunctionFactory.Create(GetWeather, "get_weather", "Get the current weather for a city"),
AIFunctionFactory.Create(GetForecast, "get_forecast", "Get a multi-day weather forecast"),
};
// Register an agent with tools
builder
.AddAIAgent(
"WeatherBot",
"You are a friendly weather assistant. Always ask the user for their city if they haven't provided it."
)
.WithAITools(weatherTools);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment