-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
yash_update
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.7
- v2.6.6
- v2.6.5
- v2.6.4
- v2.6.3
- v2.6.1
- v2.6.0
- v2.5.34
- v2.5.33
- v2.5.32
- v2.5.31
- v2.5.30
- v2.5.29
- v2.5.28
- v2.5.27
- v2.5.26
- v2.5.25
- v2.5.24
- v2.5.23
- v2.5.22
- v2.5.21
- v2.5.20
- v2.5.19.2
- v2.5.19.1
- v2.5.19
- v2.5.18
- v2.5.17
- v2.5.16
- v2.5.15
- v2.5.14
- v2.5.13
- v2.5.12
- v2.5.11
- v2.5.10
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.3.m
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.42
- v2.4.41
- v2.4.40
- v2.4.39
- v2.4.38
- v2.4.37
- v2.4.36
- v2.4.35
- v2.4.34
- v2.4.33
- v2.4.32
- v2.4.31
- v2.4.30
- v2.4.29
- v2.4.27
- v2.4.26
- v2.4.25
- v2.4.24
- v2.4.23
- v2.4.22
- v2.4.21
- v2.4.20
- v2.4.19
- v2.4.18
- v2.4.17
- v2.4.16
- v2.4.15
- v2.4.14
- v2.4.13
- v2.4.12
- v2.4.11
- v2.4.10
- v2.4.9
- v2.4.8
- v2.4.7.1
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.90
- v2.3.89
- v2.3.88
- v2.3.87
- v2.3.86
- v2.3.85
- v2.3.84
- v2.3.83
- v2.3.82
- v2.3.81
- v2.3.80
- v2.3.79
- v2.3.78
- v2.3.77
- v2.3.76
- v2.3.75
- v2.3.74
- v2.3.73
- v2.3.72
- v2.3.71
- v2.3.70
- v2.3.69
- v2.3.68
- v2.3.67
- v2.3.66
- v2.3.65
- v2.3.64.2
- v2.3.64.1
- v2.3.64
Showing
1 changed file
with
72 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,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") |