langchain_community.utilities.you.YouSearchAPIWrapper¶

class langchain_community.utilities.you.YouSearchAPIWrapper[source]¶

Bases: BaseModel

Wrapper for you.com Search and News API.

To connect to the You.com api requires an API key which you can get at https://api.you.com. You can check out the docs at https://documentation.you.com/api-reference/.

You need to set the environment variable YDC_API_KEY for retriever to operate.

ydc_api_key¶

you.com api key, if YDC_API_KEY is not set in the environment

Type

str, optional

endpoint_type¶

you.com endpoints: search, news, rag; web and snippet alias search rag returns {‘message’: ‘Forbidden’} @todo news endpoint

Type

str, optional

num_web_results¶

The max number of web results to return, must be under 20. This is mapped to the count query parameter for the News API.

Type

int, optional

safesearch¶

Safesearch settings, one of off, moderate, strict, defaults to moderate

Type

str, optional

country¶

Country code, ex: ‘US’ for United States, see api docs for list

Type

str, optional

search_lang¶

(News API) Language codes, ex: ‘en’ for English, see api docs for list

Type

str, optional

ui_lang¶
(News API) User interface language for the response, ex: ‘en’ for English,

see api docs for list

Type

str, optional

spellcheck¶

(News API) Whether to spell check query or not, defaults to True

Type

bool, optional

k¶

max number of Documents to return using results()

Type

int, optional

n_hits¶

Alias for num_web_results

Type

int, optional, deprecated

n_snippets_per_hit¶

limit the number of snippets returned per hit

Type

int, optional

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param country: Optional[str] = None¶
param endpoint_type: Literal['search', 'news', 'rag', 'snippet'] = 'search'¶
param k: Optional[int] = None¶
param n_hits: Optional[int] = None¶
param n_snippets_per_hit: Optional[int] = None¶
param num_web_results: Optional[int] = None¶
param safesearch: Optional[Literal['off', 'moderate', 'strict']] = None¶
param search_lang: Optional[str] = None¶
param spellcheck: Optional[bool] = None¶
param ui_lang: Optional[str] = None¶
param ydc_api_key: Optional[str] = None¶
raw_results(query: str, **kwargs: Any) Dict[source]¶

Run query through you.com Search and return hits.

Parameters
  • query (str) – The query to search for.

  • kwargs (Any) –

Return type

Dict

Returns: YouAPIOutput

async raw_results_async(query: str, **kwargs: Any) Dict[source]¶

Get results from the you.com Search API asynchronously.

Parameters
  • query (str) –

  • kwargs (Any) –

Return type

Dict

results(query: str, **kwargs: Any) List[Document][source]¶

Run query through you.com Search and parses results into Documents.

Parameters
  • query (str) –

  • kwargs (Any) –

Return type

List[Document]

async results_async(query: str, **kwargs: Any) List[Document][source]¶
Parameters
  • query (str) –

  • kwargs (Any) –

Return type

List[Document]

Examples using YouSearchAPIWrapper¶