usingvarclient=newGeminiClient(apiKey);varmodelId=GetGenerateContentModelId();try{vargetWeatherTool=AIFunctionFactory.Create((stringlocation)=>$"The weather in {location} is 72°F and sunny.",name:"get_weather",description:"Gets the current weather for a given location.");IChatClientchatClient=client;varupdates=chatClient.GetStreamingResponseAsync([ new ChatMessage(ChatRole.User, "What is the weather in Paris?") ],newChatOptions{ModelId=modelId,Tools=[getWeatherTool],});// Collect all streaming updatesvarfunctionCalls=newList<FunctionCallContent>();awaitforeach(varupdateinupdates){functionCalls.AddRange(update.Contents.OfType<FunctionCallContent>());}// In streaming mode, rate limiting may not throw ApiException but instead// return empty/truncated data. Treat empty results as inconclusive.if(functionCalls.Count==0){return;}}catch(ApiExceptionex)when(IsTransientAvailabilityIssue(ex)){AssertTransientAvailability(ex);}