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;varmessages=newList<Meai.ChatMessage>{new(Meai.ChatRole.User,"What is the weather in Paris?"),};// First turn: model requests tool callvarresponse=awaitchatClient.GetResponseAsync(messages,newMeai.ChatOptions{ModelId="mistral-small-latest",Tools=[getWeatherTool],});varfunctionCall=response.Messages.SelectMany(m=>m.Contents).OfType<Meai.FunctionCallContent>().FirstOrDefault();// Add assistant message with function call and tool resultmessages.AddRange(response.Messages);vartoolResult=awaitgetWeatherTool.InvokeAsync(functionCall!.Argumentsis{}args?newMeai.AIFunctionArguments(args):null);messages.Add(newMeai.ChatMessage(Meai.ChatRole.Tool,[ new Meai.FunctionResultContent(functionCall.CallId, toolResult),]));// Second turn: model should produce a final text responsevarfinalResponse=awaitchatClient.GetResponseAsync(messages,newMeai.ChatOptions{ModelId="mistral-small-latest",Tools=[getWeatherTool],});