advancedWebSearch method

LLMBuilder advancedWebSearch({
  1. WebSearchStrategy? strategy,
  2. WebSearchContextSize? contextSize,
  3. String? searchPrompt,
  4. int? maxUses,
  5. int? maxResults,
  6. List<String>? allowedDomains,
  7. List<String>? blockedDomains,
  8. WebSearchLocation? location,
  9. String? mode,
  10. String? fromDate,
  11. String? toDate,
  12. WebSearchType? searchType,
})

Advanced web search configuration with full control

This method provides access to all web search parameters and allows fine-grained control over the search behavior across all providers.

Example:

final provider = await ai()
    .anthropic()
    .apiKey(apiKey)
    .advancedWebSearch(
      strategy: WebSearchStrategy.tool,
      contextSize: WebSearchContextSize.high,
      searchPrompt: 'Focus on academic sources',
      maxUses: 3,
      allowedDomains: ['arxiv.org', 'scholar.google.com'],
    )
    .build();

Implementation

LLMBuilder advancedWebSearch({
  WebSearchStrategy? strategy,
  WebSearchContextSize? contextSize,
  String? searchPrompt,
  int? maxUses,
  int? maxResults,
  List<String>? allowedDomains,
  List<String>? blockedDomains,
  WebSearchLocation? location,
  String? mode,
  String? fromDate,
  String? toDate,
  WebSearchType? searchType,
}) {
  final config = WebSearchConfig(
    strategy: strategy ?? WebSearchStrategy.auto,
    contextSize: contextSize,
    searchPrompt: searchPrompt,
    maxUses: maxUses,
    maxResults: maxResults,
    allowedDomains: allowedDomains,
    blockedDomains: blockedDomains,
    location: location,
    mode: mode,
    fromDate: fromDate,
    toDate: toDate,
    searchType: searchType,
  );
  return extension('webSearchConfig', config);
}