-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2.3.64' of https://github.com/phidatahq/phidata into v…
…2.3.64
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 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,58 @@ | ||
from shutil import rmtree | ||
from phi.assistant.team import Assistant | ||
from phi.tools.serpapi_toolkit import SerpapiToolkit | ||
|
||
from newspaper import Article | ||
|
||
def get_article_text(url): | ||
"""Get the text of an article from a URL. | ||
Args: | ||
url (str): The URL of the article. | ||
Returns: | ||
str: The text of the article. | ||
""" | ||
article = Article(url) | ||
article.download() | ||
article.parse() | ||
return article.text | ||
|
||
|
||
search_journalist = Assistant( | ||
name="Search Journalist", | ||
role="Searches for top URLs based on a topic", | ||
description="You are a world-class search journalist. You search the web and retreive the top URLs based on a topic.", | ||
instructions=[ | ||
"Given a topic, conduct a search to find the top results.", | ||
"For a search topic, return the top 3 URLs.", | ||
], | ||
tools=[SerpapiToolkit()], | ||
# debug_mode=True, | ||
) | ||
|
||
research_journalist = Assistant( | ||
name=" Research Journalist", | ||
role="Retrives text from URLs", | ||
description="You are a world-class research journalist. You retreive the text from the URLs.", | ||
instructions=["For a list of URLs, return the text of the articles."], | ||
tools=[get_article_text], | ||
# debug_mode=True, | ||
) | ||
|
||
|
||
editor = Assistant( | ||
name="Editor", | ||
team=[search_journalist, research_journalist], | ||
description="You are the senior editor. Given a topic, use the journalists to write a NYT worthy article.", | ||
instructions=[ | ||
"Given a topic, ask the search journalist to search for the top 3 URLs.", | ||
"Then pass on these URLs to research journalist to get the text of the articles.", | ||
"Use the text of the articles to write an article about the topic.", | ||
"Make sure to write a well researched article with a clear and concise message.", | ||
"The article should be extremely articulate and well written. " | ||
"Focus on clarity, coherence, and overall quality.", | ||
], | ||
debug_mode=True, | ||
markdown=True, | ||
) | ||
|
||
editor.print_response("Write an acticle about the Anthropic claude.") |