haive.core.engine.retriever.providers.CohereRagRetrieverConfig

Cohere RAG Retriever implementation for the Haive framework.

from typing import Any This module provides a configuration class for the Cohere RAG retriever, which uses Cohere’s Retrieval-Augmented Generation API for document retrieval and generation. Cohere RAG provides enterprise-grade retrieval with built-in re-ranking, citation capabilities, and optimized retrieval performance.

The CohereRagRetriever works by: 1. Using Cohere’s RAG API for retrieval and generation 2. Automatically re-ranking results for relevance 3. Providing citations and source attribution 4. Supporting various document sources and connectors

This retriever is particularly useful when: - Need enterprise-grade RAG capabilities - Want built-in re-ranking and citation features - Building production RAG applications - Need reliable and optimized retrieval performance - Working with large document collections

The implementation integrates with LangChain’s CohereRagRetriever while providing a consistent Haive configuration interface with secure API key management.

Classes

CohereRagRetrieverConfig

Configuration for Cohere RAG retriever in the Haive framework.

Module Contents

class haive.core.engine.retriever.providers.CohereRagRetrieverConfig.CohereRagRetrieverConfig[source]

Bases: haive.core.common.mixins.secure_config.SecureConfigMixin, haive.core.engine.retriever.retriever.BaseRetrieverConfig

Configuration for Cohere RAG retriever in the Haive framework.

This retriever uses Cohere’s RAG API to provide enterprise-grade retrieval with built-in re-ranking, citations, and optimized performance.

retriever_type

The type of retriever (always COHERE_RAG).

Type:

RetrieverType

api_key

Cohere API key (auto-resolved from COHERE_API_KEY).

Type:

Optional[SecretStr]

connectors

Cohere connector configurations for data sources.

Type:

List[Dict]

top_k

Number of documents to retrieve.

Type:

int

rerank

Whether to use Cohere’s re-ranking.

Type:

bool

max_tokens

Maximum tokens for generation.

Type:

int

temperature

Temperature for generation.

Type:

float

Examples

>>> from haive.core.engine.retriever import CohereRagRetrieverConfig
>>>
>>> # Create the Cohere RAG retriever config
>>> config = CohereRagRetrieverConfig(
...     name="cohere_rag_retriever",
...     connectors=[
...         {
...             "id": "web-search",
...             "continue_on_failure": True,
...             "options": {"site": "wikipedia.org"}
...         }
...     ],
...     top_k=10,
...     rerank=True,
...     temperature=0.1
... )
>>>
>>> # Instantiate and use the retriever
>>> retriever = config.instantiate()
>>> docs = retriever.get_relevant_documents("explain quantum computing principles")
>>>
>>> # Example with custom connector
>>> custom_config = CohereRagRetrieverConfig(
...     name="custom_cohere_rag",
...     connectors=[
...         {
...             "id": "custom-docs",
...             "user_access_token": "your-token",
...             "continue_on_failure": False
...         }
...     ],
...     top_k=5
... )
get_input_fields()[source]

Return input field definitions for Cohere RAG retriever.

Return type:

dict[str, tuple[type, Any]]

get_output_fields()[source]

Return output field definitions for Cohere RAG retriever.

Return type:

dict[str, tuple[type, Any]]

instantiate()[source]

Create a Cohere RAG retriever from this configuration.

Returns:

Instantiated retriever ready for RAG operations.

Return type:

CohereRagRetriever

Raises:
  • ImportError – If required packages are not available.

  • ValueError – If API key or configuration is invalid.