usingvarclient=GetAuthenticatedOpenAiClient();Meai.IChatClientchatClient=client;vartool=Meai.AIFunctionFactory.Create((stringcity)=>cityswitch{"Paris"=>"22°C, sunny","London"=>"15°C, cloudy",_=>"Unknown",},name:"GetWeather",description:"Gets the current weather for a city");varchatOptions=newMeai.ChatOptions{ModelId=DeepInfraModel,Tools=[tool],};varmessages=newList<Meai.ChatMessage>{new(Meai.ChatRole.User,"What's the weather in Paris? Respond with the temperature only."),};// First turn — get tool callvarresponse=awaitchatClient.GetResponseAsync((IEnumerable<Meai.ChatMessage>)messages,chatOptions);varfunctionCall=response.Messages.SelectMany(m=>m.Contents).OfType<Meai.FunctionCallContent>().First();// Execute tool and add resultvartoolResult=awaittool.InvokeAsync(functionCall.Argumentsis{}args?newMeai.AIFunctionArguments(args):null);messages.AddRange(response.Messages);messages.Add(newMeai.ChatMessage(Meai.ChatRole.Tool,newMeai.AIContent[]{newMeai.FunctionResultContent(functionCall.CallId,toolResult),}));// Second turn — get final responsevarfinalResponse=awaitchatClient.GetResponseAsync((IEnumerable<Meai.ChatMessage>)messages,chatOptions);vartext=finalResponse.Messages[0].Text;Console.WriteLine($"Final response: {text}");