WatsonxRerank#
- class langchain_ibm.rerank.WatsonxRerank[source]#
Bases:
BaseDocumentCompressor
Document compressor that uses watsonx Rerank API.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- param apikey: SecretStr | None [Optional]#
API key to the Watson Machine Learning or CPD instance.
- param instance_id: SecretStr | None [Optional]#
Instance_id of the CPD instance.
- param model_id: str [Required]#
Type of model to use.
- param params: dict | RerankParameters | None = None#
Model parameters to use during request generation.
- param password: SecretStr | None [Optional]#
Password to the CPD instance.
- param project_id: str | None = None#
ID of the Watson Studio project.
- param space_id: str | None = None#
ID of the Watson Studio space.
- param streaming: bool = False#
Whether to stream the results or not.
- param token: SecretStr | None [Optional]#
Token to the CPD instance.
- param url: SecretStr [Optional]#
URL to the Watson Machine Learning or CPD instance.
- param username: SecretStr | None [Optional]#
Username to the CPD instance.
- param validate_model: bool = True#
Model ID validation.
- param verify: str | bool | None = None#
You can pass one of following as verify: * the path to a CA_BUNDLE file * the path of directory with certificates of trusted CAs * True - default path to truststore will be taken * False - no verification will be made
- param version: SecretStr | None = None#
Version of the CPD instance.
- param watsonx_client: APIClient | None = None#
- async acompress_documents(documents: Sequence[Document], query: str, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None) Sequence[Document] #
Async compress retrieved documents given the query context.
- Parameters:
documents (Sequence[Document]) β The retrieved documents.
query (str) β The query context.
callbacks (list[BaseCallbackHandler] | BaseCallbackManager | None) β Optional callbacks to run during compression.
- Returns:
The compressed documents.
- Return type:
Sequence[Document]
- compress_documents(documents: Sequence[Document], query: str, callbacks: list[BaseCallbackHandler] | BaseCallbackManager | None = None, **kwargs: Any) Sequence[Document] [source]#
Compress documents using watsonxβs rerank API.
- Parameters:
documents (Sequence[Document]) β A sequence of documents to compress.
query (str) β The query to use for compressing the documents.
callbacks (list[BaseCallbackHandler] | BaseCallbackManager | None) β Callbacks to run during the compression process.
kwargs (Any)
- Returns:
A sequence of compressed documents.
- Return type:
Sequence[Document]