This example assumes using Mistral; is in scope and apiKey contains your Mistral API key.
1 2 3 4 5 6 7 8 910111213141516171819202122
usingvarclient=newMistralClient(apiKey);vargetWeatherTool=Meai.AIFunctionFactory.Create((stringlocation)=>$"The weather in {location} is 72°F and sunny.",name:"get_weather",description:"Gets the current weather for a given location.");Meai.IChatClientchatClient=client;varresponse=awaitchatClient.GetResponseAsync([ new Meai.ChatMessage(Meai.ChatRole.User, "What is the weather in Paris?") ],newMeai.ChatOptions{ModelId="mistral-small-latest",Tools=[getWeatherTool],});varfunctionCall=response.Messages.SelectMany(m=>m.Contents).OfType<Meai.FunctionCallContent>().FirstOrDefault();