prebuilt.ai_insight.tools¶

General tools for News Reporter System.

Functions¶

export_report_json(report[, filename])

Export report data as JSON.

filter_articles_by_relevance(articles[, min_score, ...])

Filter and sort articles by relevance score.

group_articles_by_source(articles)

Group articles by their source publication.

save_report_to_file(report_content, topic[, format, ...])

Save report content to file.

search_news(config)

Search for news on any topic using Tavily API.

Module Contents¶

prebuilt.ai_insight.tools.export_report_json(report, filename=None)¶

Export report data as JSON.

Parameters:
  • report (Dict[str, Any]) – Report data to export

  • filename (Optional[str]) – Optional filename

Returns:

Path to saved JSON file

Return type:

str

prebuilt.ai_insight.tools.filter_articles_by_relevance(articles, min_score=0.5, max_articles=None)¶

Filter and sort articles by relevance score.

Parameters:
  • articles (List[haive.prebuilt.ai_insight.models.Article]) – List of articles to filter

  • min_score (float) – Minimum relevance score

  • max_articles (Optional[int]) – Maximum number to return

Returns:

Filtered and sorted articles

Return type:

List[haive.prebuilt.ai_insight.models.Article]

prebuilt.ai_insight.tools.group_articles_by_source(articles)¶

Group articles by their source publication.

Parameters:

articles (List[haive.prebuilt.ai_insight.models.Article]) – List of articles

Returns:

Dictionary mapping source to articles

Return type:

Dict[str, List[haive.prebuilt.ai_insight.models.Article]]

prebuilt.ai_insight.tools.save_report_to_file(report_content, topic, format='markdown', custom_filename=None)¶

Save report content to file.

Parameters:
  • report_content (str) – The report content to save

  • topic (str) – Topic for filename

  • format (str) – File format (markdown, html, json)

  • custom_filename (Optional[str]) – Optional custom filename

Returns:

Path to saved file

Return type:

str

prebuilt.ai_insight.tools.search_news(config)¶

Search for news on any topic using Tavily API.

Parameters:

config (haive.prebuilt.ai_insight.models.NewsSearchConfig) – Search configuration with topic and parameters

Returns:

List of found articles

Return type:

List[haive.prebuilt.ai_insight.models.Article]