Spaces:
Build error
Build error
Commit ·
3f3db0b
1
Parent(s): ca552c5
Imroved Documentation.
Browse filesFocus on tuning next, that's the only thing that's left
- README.md +48 -29
- backend/app.py +0 -2
- backend/ollama.py +0 -2
- backend/youtube.py +3 -1
- frontend/README.md +4 -49
- frontend/index.html +0 -14
README.md
CHANGED
|
@@ -1,50 +1,69 @@
|
|
| 1 |
# Précis
|
| 2 |
|
| 3 |
-
A system for compressing long-form content into clear, structured summaries.
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
-
##
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
``
|
|
|
|
| 16 |
|
| 17 |
-
##
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
-
# Dry run to validate pipeline
|
| 23 |
-
python scripts/train.py --dry-run
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
```
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
|
| 31 |
```bash
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
```
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
##
|
| 38 |
|
| 39 |
-
``
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
##
|
| 46 |
|
| 47 |
-
-
|
| 48 |
-
- `GET /health` — Health check
|
| 49 |
-
- `GET /status` — Service status and model info
|
| 50 |
-
- `POST /summarize` — Summarize content from URL (currently returns dummy data)
|
|
|
|
| 1 |
# Précis
|
| 2 |
|
| 3 |
+
A system for compressing long-form content into clear, structured summaries. Précis is designed for videos, articles, and papers. Paste a YouTube link, drop in an article, or upload a text file. Précis will pulls the key facts into a single sentence using a local LLM via [Ollama](https://ollama.com).
|
| 4 |
|
| 5 |
+
## Stack
|
| 6 |
|
| 7 |
+
| Layer | Tech |
|
| 8 |
+
|----------|------|
|
| 9 |
+
| Frontend | React 19 + Vite |
|
| 10 |
+
| Backend | FastAPI (Python) |
|
| 11 |
+
| LLM | Ollama (phi4-mini, qwen-4b) |
|
| 12 |
|
| 13 |
+
## Setup
|
| 14 |
|
| 15 |
+
### Prerequisites
|
| 16 |
|
| 17 |
+
- Python 3.11+
|
| 18 |
+
- Node.js 18+ (or [Bun](https://bun.sh))
|
| 19 |
+
- [Ollama](https://ollama.com) installed and running (`ollama serve`)
|
| 20 |
+
- At least one model pulled: `ollama pull phi4-mini:latest`
|
| 21 |
|
| 22 |
+
### Run the Fine-Tuning
|
| 23 |
|
| 24 |
+
Follow the scripts in `scripts/`, using any model you prefer. This project has been primarily tested phi4-mini (from Microsot) and Qwen 3-3b (from Alibaba).
|
| 25 |
|
| 26 |
+
### Backend
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
```bash
|
| 29 |
+
cd backend
|
| 30 |
+
pip install fastapi uvicorn httpx python-multipart youtube-transcript-api
|
| 31 |
+
uvicorn app:app --reload
|
| 32 |
```
|
| 33 |
|
| 34 |
+
Runs on `http://localhost:8000`. Interactive docs at `/docs`.
|
| 35 |
+
|
| 36 |
+
### Frontend
|
| 37 |
|
| 38 |
```bash
|
| 39 |
+
cd frontend
|
| 40 |
+
npm install # or whatever replacement for npm you may be using
|
| 41 |
+
npm run dev
|
| 42 |
```
|
| 43 |
|
| 44 |
+
Runs on `http://localhost:5173`.
|
| 45 |
|
| 46 |
+
## Features
|
| 47 |
|
| 48 |
+
- **YouTube summarization**: paste a URL, transcript is fetched automatically via `youtube-transcript-api`
|
| 49 |
+
- **Article / transcript**: paste any text directly
|
| 50 |
+
- **File upload**: drag-and-drop `.txt` files
|
| 51 |
+
- **Streaming**: summaries stream token-by-token from Ollama via NDJSON
|
| 52 |
+
- **Model switching**: choose between available Ollama models from the UI
|
| 53 |
+
|
| 54 |
+
## API Endpoints
|
| 55 |
+
|
| 56 |
+
| Method | Path | Description |
|
| 57 |
+
|--------|------|-------------|
|
| 58 |
+
| `GET` | `/health` | Health check |
|
| 59 |
+
| `GET` | `/status` | Service status, available models, Ollama reachability |
|
| 60 |
+
| `GET` | `/models` | List available models |
|
| 61 |
+
| `POST` | `/summarize/transcript` | Summarize raw text (NDJSON stream) |
|
| 62 |
+
| `POST` | `/summarize/youtube` | Summarize a YouTube video by URL (NDJSON stream) |
|
| 63 |
+
| `POST` | `/summarize/file` | Summarize an uploaded `.txt` file (NDJSON stream) |
|
| 64 |
+
|
| 65 |
+
All `/summarize/*` endpoints accept an optional `model` field to override the default.
|
| 66 |
|
| 67 |
+
## License
|
| 68 |
|
| 69 |
+
[GPL-3.0](LICENSE.md)
|
|
|
|
|
|
|
|
|
backend/app.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
"""Précis API — routes and app setup."""
|
| 2 |
-
|
| 3 |
import asyncio
|
| 4 |
from typing import Optional
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 1 |
import asyncio
|
| 2 |
from typing import Optional
|
| 3 |
|
backend/ollama.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
"""Ollama integration: prompt building, model validation, and streaming."""
|
| 2 |
-
|
| 3 |
from typing import Optional
|
| 4 |
|
| 5 |
import httpx
|
|
|
|
|
|
|
|
|
|
| 1 |
from typing import Optional
|
| 2 |
|
| 3 |
import httpx
|
backend/youtube.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
-
"""
|
|
|
|
|
|
|
| 2 |
|
| 3 |
import re
|
| 4 |
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
YouTube transcript extraction.
|
| 3 |
+
"""
|
| 4 |
|
| 5 |
import re
|
| 6 |
|
frontend/README.md
CHANGED
|
@@ -1,57 +1,12 @@
|
|
| 1 |
-
# Frontend
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
- **YouTube Video Summarization**: Paste a YouTube URL to summarize video content
|
| 8 |
-
- **Article/Transcript Summarization**: Paste any text directly to summarize
|
| 9 |
-
- **File Upload**: Drag and drop or browse for `.txt` files to summarize
|
| 10 |
-
|
| 11 |
-
## Prerequisites
|
| 12 |
-
|
| 13 |
-
- Node.js 18+ (or Bun)
|
| 14 |
-
- The backend API running at `http://localhost:8000`
|
| 15 |
-
|
| 16 |
-
## Getting Started
|
| 17 |
-
|
| 18 |
-
### 1. Install Dependencies
|
| 19 |
|
| 20 |
```bash
|
| 21 |
npm install
|
| 22 |
-
```
|
| 23 |
-
|
| 24 |
-
### 2. Start the Development Server
|
| 25 |
-
|
| 26 |
-
```bash
|
| 27 |
npm run dev
|
| 28 |
```
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
The frontend will be available at [http://localhost:5173](http://localhost:5173).
|
| 33 |
-
|
| 34 |
-
### 3. Start the Backend API (Required)
|
| 35 |
-
|
| 36 |
-
In a separate terminal, navigate to the backend directory and run:
|
| 37 |
-
|
| 38 |
-
```bash
|
| 39 |
-
cd ../backend
|
| 40 |
-
python -m uvicorn app:app --reload --host 0.0.0.0 --port 8000
|
| 41 |
-
```
|
| 42 |
-
|
| 43 |
-
## API Endpoints Used
|
| 44 |
-
|
| 45 |
-
| Endpoint | Method | Description |
|
| 46 |
-
|----------|--------|-------------|
|
| 47 |
-
| `/summarize/youtube` | POST | Summarize YouTube video |
|
| 48 |
-
| `/summarize/transcript` | POST | Summarize text content |
|
| 49 |
-
| `/summarize/file` | POST | Summarize uploaded .txt file |
|
| 50 |
-
|
| 51 |
-
## Build for Production
|
| 52 |
-
|
| 53 |
-
```bash
|
| 54 |
-
npm run build
|
| 55 |
-
```
|
| 56 |
-
|
| 57 |
-
The output will be in the `dist/` directory.
|
|
|
|
| 1 |
+
# Précis — Frontend
|
| 2 |
|
| 3 |
+
React 19 + Vite frontend for Précis. See the [root README](../README.md) for full setup instructions.
|
| 4 |
|
| 5 |
+
Navigate to the `frontend/` folder, then run:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
```bash
|
| 8 |
npm install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
npm run dev
|
| 10 |
```
|
| 11 |
|
| 12 |
+
Requires the backend API running at `http://localhost:5173`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frontend/index.html
CHANGED
|
@@ -1,14 +0,0 @@
|
|
| 1 |
-
<!doctype html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<link rel="icon" type="image/svg+xml" href="/src/assets/logo.svg" />
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
-
<meta name="description" content="Précis — Summarize YouTube videos, articles, and text files with local AI models." />
|
| 8 |
-
<title>Précis</title>
|
| 9 |
-
</head>
|
| 10 |
-
<body>
|
| 11 |
-
<div id="root"></div>
|
| 12 |
-
<script type="module" src="/src/main.jsx"></script>
|
| 13 |
-
</body>
|
| 14 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|