TrendsGPT is an automated AI agent designed for data analysis and market research. It identifies trending news articles from Reddit, determines sentiment, extracts article content, identifies key trending keywords, and even suggests T-shirt ideas based on the article content!
- Features
- Requirements
- Installation
- How to Use
- Code Overview
- Function Descriptions
- Sentiment Analysis: Uses OpenAI's GPT-4 to determine the sentiment of Reddit headlines.
- Content Extraction: Extracts the content of selected articles.
- Keyword Identification: Recognizes top keywords from the article content.
- Trend Analysis: Checks the popularity of the identified keywords using Google Trends.
- Idea Generation: Suggests T-shirt ideas based on trending keywords and article content.
- Python 3.x
- Praw, OpenAI, Requests, BeautifulSoup4, Pytrends, Pandas
- Clone this repository:
git clone <repository-link>
- Navigate to the directory and install required Python packages:
cd <repository-name>
pip install praw openai requests beautifulsoup4 pytrends pandas
- Set up your API keys:
- For Reddit (
CLIENT_ID
,CLIENT_SECRET
), get them here. - For OpenAI (
OPENAI_API_KEY
), get it from the OpenAI website.
- For Reddit (
- Run the main script:
python <script-name>.py
- Results will be saved in a CSV file named
memeworthy_articles.csv
.
The code follows these steps:
- Initialization: Set up Reddit and OpenAI clients.
- Article Collection: Fetch top weekly articles from Reddit's
nba
subreddit. - Sentiment Analysis: Analyze sentiment of headlines using OpenAI.
- Content Extraction: Extract and summarize article content.
- Keyword Identification: Recognize top keywords from the article content.
- Trend Analysis: Analyze keyword popularity using Google Trends.
- Idea Generation: Suggest T-shirt ideas using OpenAI.
- Data Storage: Store all findings in a DataFrame and export it to a CSV.
-
get_sentiment(headline)
:- Input: A string containing a headline.
- Output: Sentiment of the headline ("positive", "neutral", or "negative").
- Uses OpenAI to determine the sentiment of a given headline.
-
fetch_article_content(url, headline)
:- Input: URL of the article, and its headline.
- Output: Extracted content of the article.
- Uses
requests
andBeautifulSoup
to extract article content.
-
get_keywords_from_article(article)
:- Input: A string containing article content.
- Output: List of top keywords from the article.
- Uses OpenAI to identify and extract the top keywords from the provided article content.
-
check_google_trends(keyword)
:- Input: A keyword string.
- Output: Popularity score of the keyword using Google Trends.
- Utilizes
pytrends
to fetch the trend score of a given keyword.
-
get_tshirt_ideas(keywords, article_text)
:- Input: List of keywords and the article content.
- Output: T-shirt ideas based on the keywords and article content.
- Leverages OpenAI to suggest T-shirt ideas.
-
get_article_summary(article)
:- Input: A string containing article content.
- Output: Summarized version of the article.
- Uses OpenAI to generate a concise summary of the given article content.
Please be mindful of API rate limits, especially when making frequent requests.