Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.25.0
metadata
title: Trend Longevity Analyser
emoji: π
colorFrom: blue
colorTo: indigo
sdk: gradio
app_file: app.py
pinned: true
π Trend Longevity Analyser
A RAG-powered trend intelligence tool that classifies whether any topic is Early, Rising, at Peak, Declining, or Fading β using live news data.
How It Works
This tool implements a full 6-step RAG (Retrieval-Augmented Generation) pipeline:
| Step | What Happens |
|---|---|
| 1. Fetch | NewsAPI pulls up to 50 recent articles on your topic |
| 2. Chunk | LangChain splits articles into overlapping 400-character chunks |
| 3. Embed | all-MiniLM-L6-v2 encodes each chunk into a 384-dim vector |
| 4. Store | ChromaDB holds all vectors in an in-memory collection |
| 5. Retrieve | Semantic search returns the 10 most relevant chunks |
| 6. Generate | Gemini analyses the retrieved context and returns a structured trend signal |
Tech Stack
- Retrieval: ChromaDB (vector store) + Sentence Transformers (embeddings)
- Orchestration: LangChain text splitting
- News Data: NewsAPI (free tier)
- Generation: Google Gemini Flash (free tier)
- UI: Gradio
Setup
Running Locally
git clone https://huggingface.co/spaces/lization/trend-longevity-analyser
cd trend-longevity-analyser
pip install -r requirements.txt
export NEWSAPI_KEY=your_key_here
export ANTHROPIC_API_KEY=your_key_here
python app.py
HF Space Secrets
Set NEWSAPI_KEY and GEMINI_API_KEY as Space Secrets under Settings β Variables and Secrets. If not set, users can enter keys directly in the UI.
Get Your Free API Keys
- NewsAPI: newsapi.org/register β free tier, 100 requests/day, last 30 days of articles
- Google Gemini: aistudio.google.com β free tier, 1,500 requests/day, no credit card needed
Why RAG (Not Just a Prompt)?
Instead of passing all 50 articles to Claude (expensive, noisy, hits context limits), the RAG approach:
- Embeds every chunk as a vector
- Retrieves only the 10 most semantically relevant chunks via cosine similarity
- Passes those to Claude for analysis
This gives more focused, accurate, and cost-efficient results β and is directly analogous to production social listening systems used in enterprise contexts.
Built by Sammie Wong