webSearchSecrets function

InMemorySecretsStore webSearchSecrets({
  1. Map<String, String>? env,
})

Web search works out of the box via keyless DuckDuckGo; keyed providers (Brave, Tavily) join the chain when their API key is in the environment.

Implementation

InMemorySecretsStore webSearchSecrets({Map<String, String>? env}) {
  final environment = env ?? Platform.environment;
  return InMemorySecretsStore({
    for (final name in const ['BRAVE_API_KEY', 'TAVILY_API_KEY'])
      if (environment[name] case final value? when value.isNotEmpty)
        name: value,
  });
}