This example assumes using Cohere; is in scope and apiKey contains your Cohere API key.
1 2 3 4 5 6 7 8 91011121314151617181920
usingvarclient=GetAuthenticatedCohereClient();Meai.IChatClientchatClient=client;vargetWeatherTool=AIFunctionFactory.Create((stringlocation)=>$"The weather in {location} is sunny, 72°F","GetWeather","Gets the current weather for a location");varresponse=awaitchatClient.GetResponseAsync([new Meai.ChatMessage(Meai.ChatRole.User, "What's the weather in Seattle?")],newMeai.ChatOptions{ModelId="command-r-plus",Tools=[getWeatherTool],});varfunctionCall=response.Messages.SelectMany(m=>m.Contents).OfType<FunctionCallContent>().FirstOrDefault();