haive.core.engine.retriever.providers.AskNewsRetrieverConfigΒΆ

AskNews Retriever implementation for the Haive framework.

from typing import Any This module provides a configuration class for the AskNews retriever, which retrieves news articles and current events using AskNews API. AskNews provides access to real-time news content from various sources with filtering and categorization capabilities.

The AskNewsRetriever works by: 1. Connecting to the AskNews API 2. Executing news search queries with filters 3. Retrieving relevant news articles and metadata 4. Returning formatted documents with news content

This retriever is particularly useful when: - Building news aggregation applications - Need real-time current events information - Creating content monitoring systems - Building fact-checking or research tools - Want categorized and filtered news content

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

ClassesΒΆ

AskNewsRetrieverConfig

Configuration for AskNews retriever in the Haive framework.

Module ContentsΒΆ

class haive.core.engine.retriever.providers.AskNewsRetrieverConfig.AskNewsRetrieverConfig[source]ΒΆ

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

Configuration for AskNews retriever in the Haive framework.

This retriever searches news articles using AskNews API and returns relevant news content with metadata and categorization.

retriever_typeΒΆ

The type of retriever (always ASK_NEWS).

Type:

RetrieverType

api_keyΒΆ

AskNews API key (auto-resolved from ASKNEWS_API_KEY).

Type:

Optional[SecretStr]

kΒΆ

Number of news articles to retrieve.

Type:

int

categoriesΒΆ

News categories to filter by.

Type:

Optional[List[str]]

sourcesΒΆ

Specific news sources to include.

Type:

Optional[List[str]]

hours_backΒΆ

How many hours back to search for news.

Type:

int

Examples

>>> from haive.core.engine.retriever import AskNewsRetrieverConfig
>>>
>>> # Create the AskNews retriever config
>>> config = AskNewsRetrieverConfig(
...     name="news_retriever",
...     k=10,
...     categories=["technology", "science"],
...     hours_back=24
... )
>>>
>>> # Instantiate and use the retriever
>>> retriever = config.instantiate()
>>> docs = retriever.get_relevant_documents("artificial intelligence breakthrough")
>>>
>>> # Example with specific sources
>>> tech_config = AskNewsRetrieverConfig(
...     name="tech_news_retriever",
...     k=5,
...     sources=["techcrunch", "wired", "arstechnica"],
...     hours_back=12
... )
get_input_fields()[source]ΒΆ

Return input field definitions for AskNews retriever.

Return type:

dict[str, tuple[type, Any]]

get_output_fields()[source]ΒΆ

Return output field definitions for AskNews retriever.

Return type:

dict[str, tuple[type, Any]]

instantiate()[source]ΒΆ

Create an AskNews retriever from this configuration.

Returns:

Instantiated retriever ready for news search.

Return type:

AskNewsRetriever

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

  • ValueError – If API key or configuration is invalid.