WebSearchServiceBase
Namespace: Wisej.AI.Services
Assembly: Wisej.AI
Represents the base class for web search services, providing common functionality and properties.
- C#
- VB.NET
public class WebSearchServiceBase : IWebSearchService
Public Class WebSearchServiceBase
Inherits IWebSearchService
This abstract class implements the IWebSearchService interface and provides a foundation for web search services. It includes properties for URL configuration, query string formatting, and authentication handling.
Constructors
WebSearchServiceBase(url)
Initializes a new instance of the WebSearchServiceBase class with the specified URL.
| Name | Type | Description |
|---|---|---|
| url | String | The base URL for the web search service. |
Throws:
- ArgumentNullException Thrown when the url is null or empty.
Properties
ApiKey
String: Gets or sets the API key used for authentication. (Default: null)
Authentication
String: Gets the authentication header name. (Default: "api-key")
MaxSites
Int32: Gets or sets the maximum number of sites to search. (Default: 5)
QueryString
String: Gets or sets the query string format. (Default: "q={0}")
Url
String: Gets the base URL for the web search service.
UserAgent
String: Gets or sets the User-Agent header. (Default: "Wisej.AI (by Ice Tea Group LLC)")
Methods
GetApiKey()
Retrieves the API key for the service.
Returns: String. The API key as a string.
If the ApiKey property is not set, this method attempts to retrieve the API key from a centralized store using the service type name.
SearchAsync(query)
Performs an asynchronous search with the specified query.
| Parameter | Type | Description |
|---|---|---|
| query | String | The search query string. |
Returns: Task<String>. A task representing the asynchronous operation, with a result of the search response as a string.
Inherited By
| Name | Description |
|---|---|
| BingWebSearchService | Represents a web search service using Bing's API. |
| BraveWebSearchService | Represents a service for performing web searches using the Brave search engine. |
| GoogleWebSearchService | Represents a web search service using Google's Custom Search API. |
Implements
| Name | Description |
|---|---|
| IWebSearchService | Represents a service for performing web searches. |