LLM Demo News is a demonstration project showcasing the integration of financial news sentiment analysis using a Large Language Model (LLM). This project fetches market-related news articles, classifies their sentiment (positive, negative, neutral), and categorizes them by industry (e.g., Technology, Healthcare, etc.). It includes a backend powered by FastAPI and a React-based frontend for real-time visualization.
You will need access to an LLM, like open AI and a free finnhub API token, which you can get here: https://finnhub.io/
- News Fetching: Retrieves market news from Finnhub.
- Sentiment Analysis: Uses an LLM to classify article sentiment from -5 (negative) to 5 (positive).
- Industry Categorization: Assigns articles to specific industries based on content.
- Real-Time Dashboard: Displays a timeline of sentiment scores and categorized articles in a browser-based UI.
- Backend: FastAPI, Python
- Frontend: React, Chart.js
- Database: SQLite
- LLM Integration: Local endpoint for LLM (compatible with OpenAI APIs)
- APIs:
- Finnhub API for news data
- Custom LLM API for sentiment analysis
Ensure the following tools are installed on your system:
- Python 3.11+
- Node.js 16+
- npm 8+
- pip (Python package manager)
- Clone the Repository
git clone https://github.com/castai/llm_demo_news
cd llm-demo-new
- Create a Virtual Environment
python -m venv venv
source venv/bin/activate
- Install Dependencies
pip install -r requirements.txt
- Configure secrets in config.yaml
llm:
url: "http://localhost:8090/v1/"
api_key: "your-llm-api-key"
finnhub:
api_key: "your-finnhub-api-key"
- Run the Server
./scripts/start_server.sh
The backend will be available at http://127.0.0.1:8000
- Navigate to the dashboard
cd news-dashboard
- Install Dependancies
npm install
- Start the development server
npm run start
The frontend will be available at http://localhost:3000.
- Start both the backend and frontend servers.
- Open the frontend in your browser (http://localhost:3000).
- Use the controls to:
- Start/Stop polling news articles.
- Start/Stop classifying articles.
- Reset classifications.
- View the sentiment timeline and detailed news articles on the dashboard.