RAGchain.utils.websearch package
Submodules
RAGchain.utils.websearch.base module
- class RAGchain.utils.websearch.base.BaseWebSearch
Bases:
Runnable
[str
,RetrievalResult
],ABC
Abstract class for using a web search engine for passage contents.
- property InputType: Type[Input]
The type of input this runnable accepts specified as a type annotation.
- property OutputType: Type[Output]
The type of output this runnable produces specified as a type annotation.
- abstract get_search_data(query: str, num_results: int = 5) List[Passage]
Abstract method for searching passages from the web search engine.
- invoke(input: Input, config: RunnableConfig | None = None) Output
Invoke the WebSearch module. :param input: A query string. :param config: You can set num_results in config. The configurable key is “web_search_options”. For example,
runnable.invoke(“your search query”, config={“configurable”: {“web_search_options”: {“num_results”: 10}}})
RAGchain.utils.websearch.bing_search module
- class RAGchain.utils.websearch.bing_search.BingSearch
Bases:
BaseWebSearch
Langchain’s ‘BingSearchAPIWrapper’ returns a List[Dict[str, str]] as the return value. This BingSearch class wraps this return value in a Passage.
First, you need to set up the proper API keys and environment variables. To set it up, create the BING_SUBSCRIPTION_KEY in the Bing Search API (https://portal.azure.com/#home) and a BING_SEARCH_URL using the Bing Search API
RAGchain.utils.websearch.google_search module
- class RAGchain.utils.websearch.google_search.GoogleSearch
Bases:
BaseWebSearch
Langchain’s ‘GoogleSearchAPIWrapper’ returns a List[Dict[str, str]] as the return value. This GoogleSearch class wraps this return value in a Passage.
First, you need to set up the proper API keys and environment variables. To set it up, create the GOOGLE_API_KEY in the Google Cloud credential console (https://console.cloud.google.com/apis/credentials) and a GOOGLE_CSE_ID using the Programmable Search Engine (https://programmablesearchengine.google.com/controlpanel/create).
- batch(inputs: List[Input], config: RunnableConfig | List[RunnableConfig] | None = None, *, return_exceptions: bool = False, **kwargs: Any | None) List[Output]
Default implementation runs invoke in parallel using a thread pool executor.
The default implementation of batch works well for IO bound runnables.
Subclasses should override this method if they can batch more efficiently; e.g., if the underlying runnable uses an API which supports a batch mode.