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¶
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:
- api_key¶
Cohere API key (auto-resolved from COHERE_API_KEY).
- Type:
Optional[SecretStr]
- connectors¶
Cohere connector configurations for data sources.
- Type:
List[Dict]
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 ... )
- 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.