Newspaper4k enables an Agent to read news articles using the Newspaper4k library.

Prerequisites

The following example requires the newspaper4k and lxml_html_clean libraries.

pip install -U newspaper4k lxml_html_clean

Example

The following agent will summarize the article: https://www.rockymountaineer.com/blog/experience-icefields-parkway-scenic-drive-lifetime.

cookbook/tools/newspaper4k_tools.py
from phi.agent import Agent
from phi.tools.newspaper4k import Newspaper4k

agent = Agent(tools=[Newspaper4k()], debug_mode=True, show_tool_calls=True)
agent.print_response("Please summarize https://www.rockymountaineer.com/blog/experience-icefields-parkway-scenic-drive-lifetime")

Toolkit Params

ParameterTypeDefaultDescription
read_articleboolTrueEnables the functionality to read the full content of an article.
include_summaryboolFalseSpecifies whether to include a summary of the article along with the full content.
article_lengthint-The maximum length of the article or its summary to be processed or returned.

Toolkit Functions

FunctionDescription
get_article_dataThis function reads the full content and data of an article.
read_articleThis function reads the full content of an article.