CoolFace
Apppublic

DamnJJ/hydepark-news

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

HydePark.news - Community News Platform

HydePark.news is a lightweight, community-powered local news platform built with Python, Gradio, and Hugging Face Transformers. It allows residents to submit stories, have them processed by AI (summarization, fake news detection, optional tone analysis), reviewed by moderators, and published in a simple newsletter format.

This application is designed to be easily deployable on Hugging Face Spaces.

Core Features

  • —Story Submission: Easy-to-use Gradio form for submitting headlines, descriptions, categories, and source links.
  • —AI Summarization: Automatically summarizes long articles or descriptions using models like google/pegasus-xsum or facebook/bart-large-cnn. Fetches content from URLs if provided.
  • —Fake News Detection: Flags potentially false information using mrm8488/bert-tiny-fake-news-detection.
  • —Tone & Clarity Analysis (Optional): Uses OpenAI GPT (requires API key) to assess alignment with platform style, score clarity/style, and suggest rewrites. Can be adapted for local models.
  • —Moderation Panel: Simple Gradio interface (toggleable visibility) for reviewing pending/flagged submissions, viewing AI analysis, and approving/rejecting stories.
  • —Newsletter Builder: Generates a weekly newsletter in Markdown format from approved stories (approved.json).
  • —Static Frontend: Basic index.html and style.css provide a landing page, embed the Gradio app via iframe, explain the workflow, and link to the newsletter archive.
  • —Data Storage: Uses JSON files for simple data persistence (data/submissions.json, data/approved.json, data/rejected.json).
  • —Hugging Face Ready: Structured for straightforward deployment on Hugging Face Spaces.

Project Structure

HydePark.news/ ├── app.py # Main Gradio application logic ├── requirements.txt # Python dependencies ├── README.md # This file (with HF config block at the top!) ├── summarizer.py # Summarization functions (HF Transformers, URL fetching) ├── fakedetector.py # Fake news detection functions (HF Transformers) ├── gpttone.py # Tone/Clarity analysis functions (OpenAI) ├── datamanager.py # Handles JSON data loading and saving ├── newsletterutils.py # Newsletter generation functions ├── index.html # Static HTML homepage ├── style.css # CSS for homepage ├── .env # Optional: Store API keys locally (add to .gitignore!) ├── data/ # Data storage directory (created automatically) │ ├── submissions.json # All incoming submissions with status │ ├── approved.json # Moderated and approved stories │ └── rejected.json # Moderated and rejected stories └── issues/ # Generated newsletter markdown files (created automatically) └── dummyissueplaceholder.md # Example file for archive link

(Note: The original request mentioned `review.json`. This implementation uses a `status` field within `submissions.json` (e.g., 'pending', 'flagged_fake', 'approved', 'rejected') to track items, moving them directly to `approved.json` or `rejected.json` upon moderation. This simplifies the file management.)

Local Setup and Running

  1. 1.Clone or Download: Get all the project files into a folder on your computer (e.g., HydePark.news/).
  2. 2.Create Folders: Inside the main project folder, create empty folders named data and issues.
  3. 3.Create Virtual Environment (Recommended):
  4. 4.Open your terminal or command prompt.
  5. 5.Navigate into the project folder (cd HydePark.news).
  6. 6.Create the environment: python -m venv venv
  7. 7.Activate it:
  8. 8.Linux/macOS: source venv/bin/activate
  9. 9.Windows: venv\Scripts\activate
  10. 10.Install Dependencies:
  11. 11.Make sure your virtual environment is active.
  12. 12.Run: pip install -r requirements.txt
  13. 13.This might take time as it downloads models.
  14. 14.Configure OpenAI API Key (Optional):
  15. 15.If using the Tone Analysis feature:
  16. 16.Create a file named .env in the project root (HydePark.news/).
  17. 17.Add your key: OPENAI_API_KEY="your_openai_api_key_here"
  18. 18.Add `.env` to your `.gitignore` file if using Git.
  19. 19.Run the Gradio App:
  20. 20.In your terminal (with the virtual environment active and inside the project folder), run:
bash
        python app.py
  • —Look for a URL like http://127.0.0.1:7860 in the output and open it in your browser.

Deployment on Hugging Face Spaces

(Ensure the configuration block at the TOP of this README.md file is correct before uploading)

  1. 1.Hugging Face Account: Sign up/log in at huggingface.co.
  2. 2.Create a New Space:
  3. 3.Click your profile -> "New Space".
  4. 4.Owner/Name (e.g., YourUsername/HydePark-news).
  5. 5.SDK: "Gradio".
  6. 6.Hardware: Choose (CPU basic/upgrade recommended).
  7. 7.Visibility: Public/Private.
  8. 8.Upload Files:
  9. 9.Go to the "Files" tab of your new Space.
  10. 10.Upload all .py files, requirements.txt, README.md, index.html, style.css.
  11. 11.The data/ and issues/ folders will be created by the app, or you can create them empty.
  12. 12.Do NOT upload `.env`.
  13. 13.Add OpenAI Secret (If using):
  14. 14.Settings tab -> "Secrets" -> "New secret".
  15. 15.Name: OPENAI_API_KEY
  16. 16.Value: Paste your actual key.
  17. 17.Update `index.html` Links:
  18. 18.Edit index.html in the "Files" tab.
  19. 19.Replace all instances of YOUR-USERNAME-YOUR-SPACE-NAME with your actual Space path (e.g., YourUsername/HydePark-news).
  20. 20.Replace <YOUR_SPACE_URL_HERE> in newsletter_utils.py and app.py with your full Space URL (e.g., https://yourusername-hydepark-news.hf.space).
  21. 21.Check Logs: The Space will build and run. Monitor the "Logs" tab for errors.

How to Use the App

  1. 1.Submit: Use the "Submit a Story" tab in the Gradio interface.
  2. 2.Moderate: Use the "Moderation Panel" tab (toggle visibility) to review and Approve/Reject stories.
  3. 3.Generate Newsletter: Use the "Newsletter Builder" tab to preview and save the Markdown newsletter to the issues/ folder.
  4. 4.View Homepage/Archive: Access the static index.html page (via https://your-space-url/file=index.html) and the archive links within it.

Potential Improvements

  • —Real Authentication: Secure the moderation panel.
  • —Database Backend: Use SQLite/other DB instead of JSON for scalability.
  • —Contributor Tracking/Gamification: Implement features for frequent contributors.
  • —Robust URL Fetching: Improve web scraping reliability.
  • —Dynamic Homepage Content: Use JS to show latest headlines.
  • —Local LLM for Tone: Add option for local model analysis.
  • —Error Handling & Resilience: Improve robustness.
  • —Testing: Add automated tests.
  • —Configuration Management: Use config files/env vars for settings.