reddit and google-mail applications. This example is based on examples/reddit_summary.py.
Objective
Build an agent that, given a subreddit name and an email address:- Fetches the latest posts from the subreddit.
- Organizes posts by category (News, Discussion, etc.).
- Provides a concise summary for each category, including post titles, authors, and links.
- Sends this Markdown-formatted summary to the specified email address.
Steps
-
Set up Applications:
We need the
redditapplication to fetch posts and thegoogle-mail(or any email) application to send the summary. We’ll useapp_from_slugandAgentRIntegrationfor managing credentials via AgentR. -
Initialize LLM and ToolManager:
-
Register Tools from Applications:
The
ToolManagerwill register all tools exposed by theredditandemailapplications.This automatically makes tools likereddit_get_hot_posts(or similar, depending on the Reddit app’s implementation) andgoogle-mail_send_emailavailable. -
Get Tools in Langchain Format:
-
Create the Langchain Agent:
Define a system prompt that guides the agent through the summarization and emailing process.
-
Define the Agent’s Task Prompt:
This detailed prompt outlines the multi-step task.
-
Invoke the Agent:
Get user input for the subreddit and email, then run the agent.
How It Works
The agent will:- Use a Reddit tool (e.g.,
reddit_get_hot_posts) to fetch data from the specified subreddit. - Process this data according to the prompt (categorize, summarize). This part is done by the LLM’s reasoning.
- Once the Markdown summary is generated, it will use an email tool (e.g.,
google-mail_send_email) to send the content to the target email address.