usingvarclient=newWriterClient(apiKey);Meai.IChatClientchatClient=client;// Stream chat responses with tool calling using the MEAI IChatClient interface.// Define a simple tool that returns the current weather.vartool=Meai.AIFunctionFactory.Create((stringlocation)=>$"The weather in {location} is sunny, 72°F.","get_weather","Gets the current weather for a location.");varenumerable=chatClient.GetStreamingResponseAsync(messages:[newMeai.ChatMessage(Meai.ChatRole.User,"What's the weather in San Francisco?")],newMeai.ChatOptions{ModelId="palmyra-x-004",Tools=[tool],});varhasContent=false;Meai.ChatFinishReason?finishReason=null;awaitforeach(varupdateinenumerable){if(update.Textis{Length:>0}){Console.Write(update.Text);hasContent=true;}if(update.FinishReasonisnotnull){finishReason=update.FinishReason;}}// The model should either respond with tool calls or text content.