GoogleConnector Class
A search engine connector that uses the Google Custom Search API to perform a web search.
Initializes a new instance of the GoogleConnector class.
Constructor
GoogleConnector(api_key: str | None = None, search_engine_id: str | None = None, env_file_path: str | None = None, env_file_encoding: str | None = None)
Parameters
| Name | Description |
|---|---|
|
api_key
|
<xref:<xref:semantic_kernel.connectors.search_engine.str | None>>
The Google Custom Search API key. If provided, will override the value in the env vars or .env file. Default value: None
|
|
search_engine_id
|
<xref:<xref:semantic_kernel.connectors.search_engine.str | None>>
The Google search engine ID. If provided, will override the value in the env vars or .env file. Default value: None
|
|
env_file_path
|
<xref:<xref:semantic_kernel.connectors.search_engine.str | None>>
The optional path to the .env file. If provided, the settings are read from this file path location. Default value: None
|
|
env_file_encoding
|
<xref:<xref:semantic_kernel.connectors.search_engine.str | None>>
The optional encoding of the .env file. Default value: None
|
Methods
| search |
Returns the search results of the query provided by pinging the Google Custom search API. |
search
Returns the search results of the query provided by pinging the Google Custom search API.
async search(query: str, num_results: int = 1, offset: int = 0) -> list[str]
Parameters
| Name | Description |
|---|---|
|
query
Required
|
The search query. |
|
num_results
|
The number of search results to return. Default is 1. Default value: 1
|
|
offset
|
The offset of the search results. Default is 0. Default value: 0
|
Returns
| Type | Description |
|---|---|
|
A list of search results snippets. |