LogoLogo
HomeNewsSupportVideos
  • Welcome
  • Wisej.NET
  • Concepts
    • Getting Started
    • General Concepts
    • Architecture
    • Extensibility
    • AI Providers
    • Vector Databases
    • Usage Metrics
    • Logging & Error Handling
  • Markup
  • Components
    • API
      • SmartAdapter
        • SmartAudioTTSAdapter
        • SmartAudioWhisperAdapter
        • SmartCalendarAdapter
        • SmartChartAdapter
        • SmartChartJS3Adapter
        • SmartChatBoxAdapter
        • SmartComboBoxAdapter
        • SmartCopilotAdapter
        • SmartDataEntryAdapter
        • SmartDocumentAdapter
        • SmartFullCalendarAdapter
        • SmartObjectAdapter
        • SmartPictureBoxAdapter
        • SmartQueryAdapter
        • SmartRealtimeAdapter
        • SmartReportAdapter
        • SmartTextBoxAdapter
        • SmartAdapter.ExtendsAttribute
        • SmartAdapter.FieldNameAttribute
        • SmartAdapter.FieldPromptAttribute
        • SmartAdapter.FieldRectangleAttribute
        • SmartAdapter.WorksWithAttribute
      • SmartEndpoint
        • AmazonBedrockEndpoint
        • AnthropicEndpoint
        • AzureAIEndpoint
        • CerebrasEndpoint
        • DeepSeekEndpoint
        • GoogleAIEndpoint
        • GroqCloudEndpoint
        • GroqCloudEndpointWhisper
        • HuggingFaceEndpoint
        • HuggingFaceJavaScriptEndpoint
        • LocalAIEndpoint
        • LocalAIEndpointImageGen
        • LocalAIEndpointTTS
        • LocalAIEndpointWhisper
        • NvidiaAIEndpoint
        • OllamaEndpoint
        • OpenAIEndpoint
        • OpenAIEndpointDallE
        • OpenAIEndpointRealtime
        • OpenAIEndpointTTS
        • OpenAIEndpointWhisper
        • SambaNovaEndpoint
        • SmartHttpEndpoint
        • TogetherAIEndpoint
        • XAIEndpoint
        • SmartEndpoint.Metrics
        • SmartEndpoint.Response
      • SmartExtensions
      • SmartHub
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartObject
      • SmartPrompt
        • SmartAgentPrompt
        • SmartParallelPrompt
        • SmartPrompt.Parameter
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
      • SmartRealtimeSession
      • SmartSession
        • SmartSession.ConvertParameterEventArgs
        • SmartSession.ConvertParameterEventHandler
        • SmartSession.ErrorEventArgs
        • SmartSession.ErrorEventHandler
        • SmartSession.InvokeToolEventArgs
        • SmartSession.InvokeToolEventHandler
        • SmartSession.Message
        • SmartSession.MessageCollection
        • SmartSession.MessageRole
        • SmartSession.MessagesEventArgs
        • SmartSession.MessagesEventHandler
        • SmartSession.TrimmingStrategy
      • SmartTool
        • SmartTool.IToolProvider
        • SmartTool.ToolAttribute
        • SmartTool.ToolContext
      • Markup
        • MarkupExtensions
      • Controls
        • UVLightOverlay
      • Embeddings
        • EmbeddedDocument
        • Embedding
        • Matches
        • Metadata
      • Helpers
        • ApiKeys
        • Markdown
        • TextTokenizer
      • Services
        • DefaultSessionTrimmingService
        • IDocumentConversionService
          • DefaultDocumentConversionService
        • IEmbeddingGenerationService
          • DefaultEmbeddingGenerationService
          • HuggingFaceEmbeddingGenerationService
        • IEmbeddingStorageService
          • AzureAISearchEmbeddingStorageService
          • ChromaEmbeddingStorageService
          • FileSystemEmbeddingStorageService
          • MemoryEmbeddingStorageService
          • PineconeEmbeddingStorageService
          • QdrantEmbeddingStorageService
        • IHttpClientService
          • DefaultHttpClientService
        • ILoggerService
          • DefaultLoggerService
        • IOCRService
          • DefaultOCRService
        • IRerankingService
          • DefaultRerankingService
          • LocalAIRerankingService
          • PineconeRerankingService
        • ISessionTrimmingService
          • DefaultSessionTrimmingService
        • ITextSplitterService
          • RecursiveCharacterTextSplitterService
          • TextSplitterServiceBase
        • ITokenizerService
          • DefaultTokenizerService
        • IWebSearchService
          • BingWebSearchService
          • BraveWebSearchService
          • GoogleWebSearchService
      • Tools
        • ArxivTools
        • ChartJS3Tools
        • DatabaseTools
        • DataTableFilterTools
        • DocumentSearchTools
        • DocumentTools
        • FullCalendarTools
        • IToolsContainer
        • MathTools
        • ToolsContainer
        • UtilityTools
        • WebSearchTools
    • Built-in Services
      • IOCRService
      • ILoggerService
      • ITextSplitterService
      • ITokenizerService
      • IHttpClientService
      • IWebSearchService
      • IRerankingService
      • ISessionTrimmingService
      • IDocumentConversionService
      • IEmbeddingStorageService
      • IEmbeddingGenerationService
    • Built-in SmartTools
      • ToolsContainer
      • MathTools
      • UtilityTools
      • DatabaseTools
      • DocumentTools
      • DocumentSearchTools
      • WebSearchTools
      • ChartJS3Tools
      • FullCalendarTools
    • Built-in SmartAdapters
      • SmartAdapter
      • SmartAudioTTSAdapter
      • SmartAudioWhisperAdapter
      • SmartCalendarAdapter
      • SmartChartAdapter
      • SmartChartJS3Adapter
      • SmartChatBoxAdapter
      • SmartComboBoxAdapter
      • SmartCopilotAdapter
      • SmartDataEntryAdapter
      • SmartDocumentAdapter
      • SmartFullCalendarAdapter
      • SmartObjectAdapter
      • SmartPictureBoxAdapter
      • SmartQueryAdapter
      • SmartRealtimeAdapter
      • SmartReportAdapter
      • SmartTextBoxAdapter
    • Configure Services
    • Using SmartHub
    • Using SmartTools
    • Using SmartPrompt
    • Using SmartSession
    • Using SmartRealTimeAdapter
    • UVLightOverlay Control
Powered by GitBook
On this page
  • Overview
  • Using WebSearchTools
  • Properties
  • Services
Export as PDF
  1. Components
  2. Built-in SmartTools

WebSearchTools

PreviousDocumentSearchToolsNextChartJS3Tools

Last updated 16 days ago

Overview

WebSearchTools class offers a set of functions to search and retrieve content from the web. It utilizes the to interact with various web search providers.

It can download HTML pages as well as any document format supported by the current . Additionally, it handles redirects and deflated (compressed) responses.

Please note that executing JavaScript and loading images on web pages is not supported.

The search functionality is achieved by offering two methods to the AI. The search method executes a search query and returns relevant URLs along with page content snippets. The read method extracts content from the list of URLs selected by the AI.

When the tool downloads content, it does not employ vectorization to condense the text into relevant segments. Instead, it returns the full text content, truncated to the MaxContextToken property value (default is 4096 tokens). This limit applies to each page being read. Therefore, if the AI uses the tool to read multiple pages and the MaxContextToken is set too high, you may exceed the ContextWindow of the current endpoint.

Using WebSearchTools

To enable the use of simply add it to a SmartHub, SmartAdapter, or SmartPrompt.

this.smartDataEntryAdapter1
    .UseTools(
        new WebSearchTools());

You can add WebSearchTools to any adapter or prompt to enhance their core functionality in conjunction with other tools. For instance, when paired with the , it empowers the AI to fill in missing data by conducting web searches.

Properties

Name
Description

MaxSites

Read-write and overridable. Default is 5. The MaxSites property limits the number of sites returned by the search engine.

MaxContextTokens

Read-write and overridable. Default is 4096. The MaxContextTokens property is responsible for truncating the content of a single web page when it is converted to text. This truncation is necessary to create the Retrieval-Augmented Generation (RAG) string efficiently.

UserAgent

Read-write and overridable. Default is Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36. The tool is designed to mimic a desktop browser when accessing websites to prevent being blocked or throttled.

Timeout

Read-write and overridable. Default is 30000. The Timeout property specifies the maximum duration, in milliseconds, that the system will wait to read the content of a web page before aborting the request.

Services

There is no default IWebSearchService installed. To use the WebSearchTools object, you must register a web search service. The currently available built-in services are: BingWebSearchService, GoogleWebSearchService, and BraveWebSearchService. Each requires an API key, and for GoogleWebSearchService, an engine ID is also needed (please refer to Google's documentation for more details).

Here is how to register the BingWebSearchService during startup:

internal static class Program
{
  static Program()
  {
    Application.Services
      .AddOrReplaceService<IWebSearchService, BingWebSearchService>();
  }
}
Module Program
    Shared Sub New()
        Application.Services.AddOrReplaceService( _
            Of IWebSearchService, BingWebSearchService)()
    End Sub
End Class
internal static class Program
{
  static Program()
  {
    Application.Services
      .AddOrReplaceService<IWebSearchService>(new BingWebSearchService {
          ApiKey = "..."
    })
  }
}
Module Program
    Shared Sub New()
        Application.Services.AddOrReplaceService( _
            Of IWebSearchService, New BingWebSearchService With {
                .ApiKey = "..."
            })()
    End Sub
End Class

The tool also utilizes the IDocumentConversionService to convert HTML content into plain text. The default implementation provided by Wisej.AI leverages the HtmlAgilityPack, a library designed for parsing HTML content. It processes HTML by breaking it down and subsequently reassembling it into a coherent and usable text format.

If you prefer to specify the API key directly in the code, instead of using the file or environment variables, use the following code:

Refer to for more information on how to implement and use a custom web search provider.

IWebSearchService
IDocumentConversionService
WebSearchTools
SmartObjectAdapter
IWebSearchService
ApiKeys.json