Spaces:
Runtime error
Runtime error
Upload 6 files
Browse filesInitial upload of NewsLetter app
- config/agents.yaml +135 -0
- config/newsletter_template.html +84 -0
- config/tasks.yaml +110 -0
- tools/__init__.py +0 -0
- tools/__pycache__/custom_tool.cpython-312.pyc +0 -0
- tools/custom_tool.py +71 -0
config/agents.yaml
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
researcher:
|
| 2 |
+
role: >
|
| 3 |
+
Senior Researcher
|
| 4 |
+
goal: >
|
| 5 |
+
Uncover cutting-edge developments in {topic}.
|
| 6 |
+
backstory: >
|
| 7 |
+
You're a seasoned journalist with a nose for news. You're known for your great research skills and ability to dig up the most interesting stories. Your reports are always thorough and well-researched, making you a trusted source of information.
|
| 8 |
+
You always follow the rules and guidelines provided to you and you never forget to include the complete URL of the article where you found the news.
|
| 9 |
+
|
| 10 |
+
editor:
|
| 11 |
+
role: >
|
| 12 |
+
Editor-in-Chief
|
| 13 |
+
goal: >
|
| 14 |
+
Ensure the quality and accuracy of the final newsletter.
|
| 15 |
+
backstory: >
|
| 16 |
+
You are the Editor-in-Chief of a prestigious news organization. You are responsible for overseeing the production of the newsletter and ensuring that it meets the highest standards of quality, that it is accurate, well-written, and engaging.
|
| 17 |
+
|
| 18 |
+
You review the news articles provided by the researcher, add context to each article (like why the news story is relevant), and have a great sense of what will resonate with the readers. You use this sense of judgment to reorder the news articles in a way that the most important news is at the top of the list.
|
| 19 |
+
|
| 20 |
+
designer:
|
| 21 |
+
role: >
|
| 22 |
+
Newsletter Compiler
|
| 23 |
+
goal: >
|
| 24 |
+
Fill the HTML template given to you with the news articles provided.
|
| 25 |
+
backstory: >
|
| 26 |
+
You are responsible for compiling the HTML code of the newsletter, making sure that every news article is included in the final document.
|
| 27 |
+
You do NOT modify the content and only update the design when necessary. You use the HTML template provided to you to create the newsletter.
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
config/newsletter_template.html
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html>
|
| 3 |
+
<head>
|
| 4 |
+
<title>Weekly Newsletter</title>
|
| 5 |
+
<style>
|
| 6 |
+
body {
|
| 7 |
+
font-family: Arial, sans-serif;
|
| 8 |
+
margin: 0;
|
| 9 |
+
padding: 0;
|
| 10 |
+
background-color: #f0f0f0;
|
| 11 |
+
}
|
| 12 |
+
.container {
|
| 13 |
+
width: 80%;
|
| 14 |
+
margin: auto;
|
| 15 |
+
padding: 20px;
|
| 16 |
+
background-color: #fff;
|
| 17 |
+
border-radius: 5px;
|
| 18 |
+
box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
|
| 19 |
+
}
|
| 20 |
+
h1, h2 {
|
| 21 |
+
color: #333;
|
| 22 |
+
}
|
| 23 |
+
h1 {
|
| 24 |
+
text-align: center;
|
| 25 |
+
margin-bottom: 20px;
|
| 26 |
+
}
|
| 27 |
+
h2 {
|
| 28 |
+
margin: 0;
|
| 29 |
+
}
|
| 30 |
+
p {
|
| 31 |
+
color: #666;
|
| 32 |
+
line-height: 1.5;
|
| 33 |
+
}
|
| 34 |
+
ul {
|
| 35 |
+
list-style-type: none;
|
| 36 |
+
padding: 0;
|
| 37 |
+
}
|
| 38 |
+
li {
|
| 39 |
+
margin-bottom: 20px;
|
| 40 |
+
}
|
| 41 |
+
.read-more {
|
| 42 |
+
margin-top: 10px;
|
| 43 |
+
font-size: 14px;
|
| 44 |
+
}
|
| 45 |
+
.read-more a {
|
| 46 |
+
color: #0066cc;
|
| 47 |
+
text-decoration: none;
|
| 48 |
+
}
|
| 49 |
+
.read-more a:hover {
|
| 50 |
+
text-decoration: underline;
|
| 51 |
+
}
|
| 52 |
+
.goodbye {
|
| 53 |
+
text-align: center;
|
| 54 |
+
margin-top: 30px;
|
| 55 |
+
color: #666;
|
| 56 |
+
}
|
| 57 |
+
</style>
|
| 58 |
+
</head>
|
| 59 |
+
<body>
|
| 60 |
+
<div class="container">
|
| 61 |
+
<h1><!-- TITLE OF THE DAY --></h1>
|
| 62 |
+
<p><!-- PERSONAL MESSAGE --></p>
|
| 63 |
+
<ul>
|
| 64 |
+
<li>
|
| 65 |
+
<h2><!-- TITLE OF THE STORY --></h2>
|
| 66 |
+
<p><!-- SUMMARY OF THE STORY --></p>
|
| 67 |
+
<p><!-- WHY THIS IS IMPORTANT --></p>
|
| 68 |
+
<div class="read-more">
|
| 69 |
+
<p>Read more:</p>
|
| 70 |
+
<ul>
|
| 71 |
+
<li><a href="https://www.example.com"><!-- LINK 1 --></a>
|
| 72 |
+
<li><a href="https://www.example2.com"><!-- LINK 2 --></a>
|
| 73 |
+
</ul>
|
| 74 |
+
</div>
|
| 75 |
+
</li>
|
| 76 |
+
|
| 77 |
+
<!-- ADD ALL THE OTHER NEWS ITEMS HERE USING THE SAME FORMAT AS THE EXAPLE ABOVE -->
|
| 78 |
+
</ul>
|
| 79 |
+
<p class="goodbye">Goodbye and see you tomorrow!</p>
|
| 80 |
+
</div>
|
| 81 |
+
</body>
|
| 82 |
+
</html>
|
| 83 |
+
|
| 84 |
+
|
config/tasks.yaml
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
research_task:
|
| 2 |
+
description: >
|
| 3 |
+
Conduct a thorough research about the latest news on {topic}. Be sure to look for sources that are reliable and publish recent news. Do not include articles that are not news material or that are not directly related to {topic}.
|
| 4 |
+
With this research, compile a list of the most relevant news stories that you found.
|
| 5 |
+
|
| 6 |
+
Follow these rules:
|
| 7 |
+
- Only include articles that are especially relevant to {topic}. Do not include any news that are not directly related to {topic}.
|
| 8 |
+
- Do not include sources that are not a news article. If the content of the page includes a list of articles or looks like the front page of a website, do not include it in the list!
|
| 9 |
+
- Summarize the news in a few sentences. Make the summary as long as necessary to include all the relevant information, but not too long for a newsletter.
|
| 10 |
+
- Include the URL of the article where you found the news.
|
| 11 |
+
- Include a minimum of 2 news articles and a maximum of 3 news articles in the list.
|
| 12 |
+
- When using the Search Tool, your search query should be concise (for example, "latest news on {topic}").
|
| 13 |
+
|
| 14 |
+
IMPORTANT INSTRUCTIONS ABOUT USING TOOLS: When using tools, DO NOT ESCAPE the underscore character "_", EVER. If you need to use a tool and pass in a parameter called 'search_query', you should write 'search_query', not 'search\_query'. THIS IS VERY IMPORTANT, else the tool will not work.
|
| 15 |
+
|
| 16 |
+
expected_output: >
|
| 17 |
+
A markdown document with the most relevant news stories. Each news story should contain the following:
|
| 18 |
+
- Title of the news
|
| 19 |
+
- Summary of the news
|
| 20 |
+
- URL of the article where the news was found
|
| 21 |
+
|
| 22 |
+
Here is an example of the format of a news article that you could include in the document:
|
| 23 |
+
|
| 24 |
+
<EXAMPLE>
|
| 25 |
+
Story 1:
|
| 26 |
+
- Title: **Daily briefing: AI now beats humans at basic reading and maths**
|
| 27 |
+
- **Summary:** AI systems can now nearly match and sometimes exceed human performance in basic tasks. The report discusses the need for new benchmarks to assess AI capabilities and highlights the ethical considerations for AI models.
|
| 28 |
+
- **URL:** [Nature Article](https://www.nature.com/articles/d41586-024-01125-1)
|
| 29 |
+
</EXAMPLE>
|
| 30 |
+
|
| 31 |
+
edit_task:
|
| 32 |
+
description: >
|
| 33 |
+
Given the list of news articles that will be used in the newsletter do the following things:
|
| 34 |
+
|
| 35 |
+
- Rewrite the title of each news article to make it more engaging and interesting for the readers of the newsletter.
|
| 36 |
+
- Write an extra paragraph that explains why the article is important.(don't just rewrite it)
|
| 37 |
+
|
| 38 |
+
IMPORTANT INSTRUCTION: You shall not use any tools just do the assigned task exceptionally.
|
| 39 |
+
|
| 40 |
+
expected_output: >
|
| 41 |
+
A markdown document with all the news to be included in the newsletter of the week. The document should have a title related to the curated stories of the week and a list of news articles.
|
| 42 |
+
|
| 43 |
+
Each one should contain:
|
| 44 |
+
- Title:
|
| 45 |
+
- Summary:
|
| 46 |
+
- Why this is important:
|
| 47 |
+
- Source: [URL of the article]
|
| 48 |
+
|
| 49 |
+
Here is an example of a document that you are expected to produce:
|
| 50 |
+
<EXAMPLE>
|
| 51 |
+
Title of the day: AI is taking over the world
|
| 52 |
+
|
| 53 |
+
- **Title:** AI Surpasses Human Capabilities in Basic Reading and Maths
|
| 54 |
+
**Summary:** Recent advancements in AI technology have enabled systems to match and sometimes exceed human performance in fundamental tasks such as reading and arithmetic. This shift necessitates the creation of new benchmarks to appropriately evaluate AI capabilities.
|
| 55 |
+
**Why this is important:** This development is crucial as it not only showcases the rapid progress in AI but also prompts a reevaluation of how AI is integrated into educational and professional settings. It raises significant ethical questions about the future role of AI in society.
|
| 56 |
+
**Source:** "Title of the article" by ["Source"](https://www.nature.com/articles/d41586-024-01125-1)
|
| 57 |
+
|
| 58 |
+
[... more news articles ...]
|
| 59 |
+
|
| 60 |
+
</EXAMPLE>
|
| 61 |
+
|
| 62 |
+
newsletter_task:
|
| 63 |
+
description: >
|
| 64 |
+
Fill the following HTML template with exactly the same information that is given to you. Also, include the following personal message at the beginning of the newsletter in the space provided: {personal_message}
|
| 65 |
+
|
| 66 |
+
(If there is no personal message, leave the space empty.)
|
| 67 |
+
|
| 68 |
+
IMPORTANT INSTRUCTION:
|
| 69 |
+
Create only that many articles which are provided to you. Do not replicate or add any content to the articles provided. Do not hallucinate content. Do not invent facts.
|
| 70 |
+
|
| 71 |
+
For each article:
|
| 72 |
+
- Preserve the exact title, summary, and structure.
|
| 73 |
+
- Provide the correct and complete URL corresponding to each article. Never generate or invent a link. If no link is provided, leave the "Read more" section out for that article.
|
| 74 |
+
- DO NOT rewrite, rephrase, or summarize any of the content. Just place the provided content correctly into the template.
|
| 75 |
+
|
| 76 |
+
IMPORTANT STYLE INSTRUCTIONS:
|
| 77 |
+
- Use only inline CSS styles. Do not use external stylesheets or `<link>` tags.
|
| 78 |
+
- Ensure that the personal message, headings, and all text are clearly visible:
|
| 79 |
+
- Title and headings must use color: #222 or darker.
|
| 80 |
+
- Paragraphs must use color: #444 or darker and line-height: 1.6.
|
| 81 |
+
- Avoid using transparent or very light grey colors (e.g., #aaa or #ccc).
|
| 82 |
+
- Use `<h1 style="color:#222;">`, `<h2 style="color:#222;">`, and `<p style="color:#444; line-height:1.6;">` formats for maximum readability.
|
| 83 |
+
- The newsletter background should be light (#ffffff or #f9f9f9), and the text should contrast well.
|
| 84 |
+
- The personal message must appear at the top in a `<p>` tag and should follow the same dark styling.
|
| 85 |
+
|
| 86 |
+
✅ Example:
|
| 87 |
+
<h2 style="color:#222;">Article Title</h2>
|
| 88 |
+
<p style="color:#444; line-height:1.6;">This is the summary...</p>
|
| 89 |
+
|
| 90 |
+
✅ Example Read More:
|
| 91 |
+
<a href="https://example.com/article-link" style="color: #0066cc;">Read full article</a>
|
| 92 |
+
|
| 93 |
+
{html_template}
|
| 94 |
+
|
| 95 |
+
expected_output: >
|
| 96 |
+
Return ONLY the HTML content filled with the given information.
|
| 97 |
+
- DO NOT include triple backticks like ``` or ```html or any code fences.
|
| 98 |
+
- DO NOT include any explanations or extra messages.
|
| 99 |
+
- DO NOT change or skip any article or URL.
|
| 100 |
+
- Output must be valid HTML and renderable directly.
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
|
tools/__init__.py
ADDED
|
File without changes
|
tools/__pycache__/custom_tool.cpython-312.pyc
ADDED
|
Binary file (3.08 kB). View file
|
|
|
tools/custom_tool.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from crewai.tools import BaseTool
|
| 2 |
+
from exa_py import Exa
|
| 3 |
+
import os
|
| 4 |
+
from datetime import datetime, timedelta
|
| 5 |
+
|
| 6 |
+
class SearchAndContents(BaseTool):
|
| 7 |
+
name: str = "Search and Contents Tool"
|
| 8 |
+
description: str = (
|
| 9 |
+
"Searches the web based on a search query for the latest results. Results are only from the last week. Uses the Exa API. This also returns the contents of the search results."
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
def _run(self, search_query: str) -> str:
|
| 13 |
+
|
| 14 |
+
exa = Exa(api_key=os.getenv("EXA_KEY"))
|
| 15 |
+
|
| 16 |
+
one_week_ago = datetime.now() - timedelta(days=7)
|
| 17 |
+
date_cutoff = one_week_ago.strftime("%Y-%m-%d")
|
| 18 |
+
|
| 19 |
+
search_results = exa.search_and_contents(
|
| 20 |
+
query=search_query,
|
| 21 |
+
num_results=2,
|
| 22 |
+
use_autoprompt=True,
|
| 23 |
+
start_published_date=date_cutoff,
|
| 24 |
+
text={"include_html_tags": False, "max_characters": 3000},
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
return search_results
|
| 28 |
+
|
| 29 |
+
class FindSimilar(BaseTool):
|
| 30 |
+
name: str = "Find Similar Tool"
|
| 31 |
+
description: str = (
|
| 32 |
+
"Searches for similar articles to a given article using the Exa API. Takes in a URL of the article"
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
def _run(self, article_url: str) -> str:
|
| 36 |
+
|
| 37 |
+
one_week_ago = datetime.now() - timedelta(days=7)
|
| 38 |
+
date_cutoff = one_week_ago.strftime("%Y-%m-%d")
|
| 39 |
+
|
| 40 |
+
exa = Exa(api_key=os.getenv("EXA_KEY"))
|
| 41 |
+
search_results = exa.find_similar(
|
| 42 |
+
url=article_url, num_results=1, start_published_date=date_cutoff
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
return search_results
|
| 46 |
+
|
| 47 |
+
class GetContents(BaseTool):
|
| 48 |
+
name: str = "Get Contents Tool"
|
| 49 |
+
description: str = "Gets the contents of a specific article using the Exa API. Takes in the ID of the article in a list, like this: ['https://www.cnbc.com/2024/04/18/my-news-story']."
|
| 50 |
+
|
| 51 |
+
def _run(self, article_ids: str) -> str:
|
| 52 |
+
|
| 53 |
+
exa = Exa(api_key=os.getenv("EXA_KEY"))
|
| 54 |
+
contents = exa.get_contents(article_ids[:1])
|
| 55 |
+
return contents
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
|