Skip to content

Commit

Permalink
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions cookbook/teams/journalist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from pathlib import Path
from shutil import rmtree
from phi.assistant.team import Assistant
from phi.tools.yfinance import YFinanceTools
from phi.tools.file import FileTools
from phi.tools.serpapi_toolkit import SerpapiToolkit

import requests
from bs4 import BeautifulSoup
from newspaper import Article
import ast


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.")

# test = Assistant(
# tools=[get_article_text],
# debug_mode=True,
# )

# test.print_response("https://en.wikipedia.org/wiki/Solar_eclipse_of_April_8,_2024")

0 comments on commit 36be83f

Please sign in to comment.