langchain.retrievers.google_cloud_enterprise_search.GoogleCloudEnterpriseSearchRetriever

class langchain.retrievers.google_cloud_enterprise_search.GoogleCloudEnterpriseSearchRetriever(*, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, project_id: str, search_engine_id: str, serving_config_id: str = 'default_config', location_id: str = 'global', filter: Optional[str] = None, get_extractive_answers: bool = False, max_documents: ConstrainedIntValue = 5, max_extractive_answer_count: ConstrainedIntValue = 1, max_extractive_segment_count: ConstrainedIntValue = 1, query_expansion_condition: ConstrainedIntValue = 1, credentials: Any = None)[source]

Bases: BaseRetriever

Retriever for the Google Cloud Enterprise Search Service API.

For the detailed explanation of the Enterprise Search concepts and configuration parameters refer to the product documentation.

https://cloud.google.com/generative-ai-app-builder/docs/enterprise-search-introduction

Initializes private fields.

param credentials: Any = None

The default custom credentials (google.auth.credentials.Credentials) to use when making API calls. If not provided, credentials will be ascertained from the environment.

param filter: Optional[str] = None

Filter expression.

param get_extractive_answers: bool = False

If True return Extractive Answers, otherwise return Extractive Segments.

param location_id: str = 'global'

Enterprise Search engine location.

param max_documents: int = 5

The maximum number of documents to return.

Constraints
  • minimum = 1

  • maximum = 100

param max_extractive_answer_count: int = 1

The maximum number of extractive answers returned in each search result. At most 5 answers will be returned for each SearchResult.

Constraints
  • minimum = 1

  • maximum = 5

param max_extractive_segment_count: int = 1

The maximum number of extractive segments returned in each search result. Currently one segment will be returned for each SearchResult.

Constraints
  • minimum = 1

  • maximum = 1

param metadata: Optional[Dict[str, Any]] = None

Optional metadata associated with the retriever. Defaults to None This metadata will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a retriever with its use case.

param project_id: str [Required]

Google Cloud Project ID.

param query_expansion_condition: int = 1

Specification to determine under which conditions query expansion should occur. 0 - Unspecified query expansion condition. In this case, server behavior defaults

to disabled

1 - Disabled query expansion. Only the exact search query is used, even if

SearchResponse.total_size is zero.

2 - Automatic query expansion built by the Search API.

Constraints
  • minimum = 0

  • maximum = 2

param search_engine_id: str [Required]

Enterprise Search engine ID.

param serving_config_id: str = 'default_config'

Enterprise Search serving config ID.

param tags: Optional[List[str]] = None

Optional list of tags associated with the retriever. Defaults to None These tags will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks. You can use these to eg identify a specific instance of a retriever with its use case.

async aget_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) List[Document]

Asynchronously get documents relevant to a query. :param query: string to find relevant documents for :param callbacks: Callback manager or list of callbacks :param tags: Optional list of tags associated with the retriever. Defaults to None

These tags will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.

Parameters

metadata – Optional metadata associated with the retriever. Defaults to None This metadata will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.

Returns

List of relevant documents

async ainvoke(input: str, config: Optional[RunnableConfig] = None) List[Document]
get_relevant_documents(query: str, *, callbacks: Callbacks = None, tags: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None, **kwargs: Any) List[Document]

Retrieve documents relevant to a query. :param query: string to find relevant documents for :param callbacks: Callback manager or list of callbacks :param tags: Optional list of tags associated with the retriever. Defaults to None

These tags will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.

Parameters

metadata – Optional metadata associated with the retriever. Defaults to None This metadata will be associated with each call to this retriever, and passed as arguments to the handlers defined in callbacks.

Returns

List of relevant documents

invoke(input: str, config: Optional[RunnableConfig] = None) List[Document]
to_json() Union[SerializedConstructor, SerializedNotImplemented]
to_json_not_implemented() SerializedNotImplemented
validator validate_environment  »  all fields[source]

Validates the environment.

property lc_attributes: Dict

Return a list of attribute names that should be included in the serialized kwargs. These attributes must be accepted by the constructor.

property lc_namespace: List[str]

Return the namespace of the langchain object. eg. [“langchain”, “llms”, “openai”]

property lc_secrets: Dict[str, str]

Return a map of constructor argument names to secret ids. eg. {“openai_api_key”: “OPENAI_API_KEY”}

property lc_serializable: bool

Return whether or not the class is serializable.

model Config[source]

Bases: object

Configuration for this pydantic object.

arbitrary_types_allowed = True
extra = 'forbid'
underscore_attrs_are_private = True

Examples using GoogleCloudEnterpriseSearchRetriever