Skip to content

castai/llm-demo-news

 
 

Repository files navigation

LLM Demo News

Overview

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/

Features

  • 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.

Tech Stack

  • 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

Setup

Prerequisites

Ensure the following tools are installed on your system:

  • Python 3.11+
  • Node.js 16+
  • npm 8+
  • pip (Python package manager)

Backend Installation

  1. Clone the Repository
git clone https://github.com/castai/llm_demo_news
cd llm-demo-new
  1. Create a Virtual Environment
python -m venv venv
source venv/bin/activate
  1. Install Dependencies
pip install -r requirements.txt
  1. Configure secrets in config.yaml
llm:
  url: "http://localhost:8090/v1/"
  api_key: "your-llm-api-key"

finnhub:
  api_key: "your-finnhub-api-key"
  1. Run the Server
./scripts/start_server.sh

The backend will be available at http://127.0.0.1:8000

Frontend Installation

  1. Navigate to the dashboard
cd news-dashboard
  1. Install Dependancies
npm install
  1. Start the development server
npm run start

The frontend will be available at http://localhost:3000.

Usage

  1. Start both the backend and frontend servers.
  2. Open the frontend in your browser (http://localhost:3000).
  3. Use the controls to:
    • Start/Stop polling news articles.
    • Start/Stop classifying articles.
    • Reset classifications.
  4. View the sentiment timeline and detailed news articles on the dashboard.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 50.5%
  • JavaScript 36.4%
  • HTML 4.8%
  • CSS 3.4%
  • Shell 2.7%
  • Dockerfile 2.2%