forked from agno-agi/agno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86b4abc
commit 0d1753e
Showing
12 changed files
with
83 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from phi.assistant import Assistant | ||
from phi.tools.duckduckgo import DuckDuckGo | ||
from phi.tools.newspaper4k import Newspaper4k | ||
|
||
assistant = Assistant( | ||
tools=[DuckDuckGo(), Newspaper4k()], | ||
show_tool_calls=True, | ||
description="You are a senior NYT researcher writing an article on a topic.", | ||
instructions=[ | ||
"For the provided topic, search for the top 3 links.", | ||
"Then read each URL and extract the article text. If a URL isn't available, ignore and move on.", | ||
"Analyse and prepare an NYT worthy article based on the information.", | ||
], | ||
add_datetime_to_instructions=True, | ||
) | ||
assistant.print_response("Latest developments in AI", markdown=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import json | ||
from phi.tools import Toolkit | ||
|
||
try: | ||
import newspaper | ||
except ImportError: | ||
raise ImportError("`newspaper4k` not installed. Please run `pip install newspaper4k lxml_html_clean`.") | ||
|
||
|
||
class Newspaper4k(Toolkit): | ||
def __init__( | ||
self, | ||
read_article: bool = True, | ||
include_summary: bool = False, | ||
): | ||
super().__init__(name="newspaper_toolkit") | ||
|
||
self.include_summary: bool = include_summary | ||
if read_article: | ||
self.register(self.read_article) | ||
|
||
def read_article(self, url: str) -> str: | ||
"""Get the article information from a URL. | ||
Args: | ||
url (str): The URL of the article. | ||
Returns: | ||
str: JSON containing the article author, publish date, and text. | ||
""" | ||
|
||
try: | ||
article = newspaper.article(url) | ||
article_data = {} | ||
if article.title: | ||
article_data["title"] = article.title | ||
if article.authors: | ||
article_data["authors"] = article.authors | ||
if article.text: | ||
article_data["text"] = article.text | ||
if self.include_summary and article.summary: | ||
article_data["summary"] = article.summary | ||
|
||
try: | ||
if article.publish_date: | ||
article_data["publish_date"] = article.publish_date.isoformat() if article.publish_date else None | ||
except Exception: | ||
pass | ||
|
||
return json.dumps(article_data, indent=2) | ||
except Exception as e: | ||
return f"Error reading article from {url}: {e}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
[project] | ||
name = "phidata" | ||
version = "2.3.68" | ||
description = "Build AI Assistants using function calling" | ||
version = "2.3.69" | ||
description = "Build AI Assistants with memory, knowledge and tools." | ||
requires-python = ">=3.8" | ||
readme = "README.md" | ||
authors = [ | ||
{name = "Ashpreet Bedi", email = "[email protected]"} | ||
] | ||
|
||
dependencies = [ | ||
"boto3", | ||
"botocore", | ||
"docker", | ||
"gitpython", | ||
"httpx", | ||
"pydantic", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters