Skip to main content

Summarize web pages and YouTube videos with pluggable LLM backends (Ollama, OpenAI).

Project description

websum

CI Python PyPI License: MIT

Summarize web pages and YouTube videos with pluggable LLM backends. Ships with first-class support for Ollama (local) and OpenAI, plus an optional Gradio web UI.

Installation

# Library + CLI, with Ollama backend
pip install 'websum[ollama]'

# With OpenAI backend
pip install 'websum[openai]'

# With the Gradio web UI
pip install 'websum[ui,ollama]'

# Everything
pip install 'websum[all]'

Using uv:

uv add 'websum[ollama]'

Quickstart

Library

from websum import Summarizer, OllamaBackend

s = Summarizer(backend=OllamaBackend(model="llama3:instruct"))
print(s.summarize("https://cobanov.dev/haftalik-bulten/hafta-13"))
print(s.summarize("https://www.youtube.com/watch?v=4pOpQwiUVXc"))
print(s.translate("Hello world", target_language="Turkish"))

Swap the backend without touching anything else:

from websum import Summarizer, OpenAIBackend

s = Summarizer(backend=OpenAIBackend(model="gpt-4o-mini"))

CLI

# Summarize a web page or YouTube URL (auto-detected)
websum summarize https://example.com

# Use OpenAI instead of Ollama
websum summarize https://example.com --backend openai --model gpt-4o-mini

# Translate
websum translate "Hello world" --target-language Turkish

# Launch the Gradio UI
websum ui --port 7860

Run websum --help for the full command reference.

API overview

Object Purpose
Summarizer High-level API. summarize(url), summarize_web(url), summarize_youtube(url), translate(text).
SummarizerConfig Chunking and language settings.
OllamaBackend, OpenAIBackend Built-in backends. Frozen dataclasses with .build().
LLMBackend (Protocol) Implement this to plug in any backend.
BackendRegistry Map string names to backend classes (used by the CLI).

All public names are re-exported from the top-level websum package and listed in __all__.

Custom backends

from dataclasses import dataclass
from websum import LLMBackend, Summarizer

@dataclass
class MyBackend:
    def build(self):
        from langchain_anthropic import ChatAnthropic
        return ChatAnthropic(model="claude-3-5-sonnet-latest")

assert isinstance(MyBackend(), LLMBackend)  # Protocol check
s = Summarizer(backend=MyBackend())

Docker

docker build -t websum .
docker run -p 7860:7860 websum

# Run when ollama is on the host
docker run --network host -p 7860:7860 websum

The image starts websum ui by default.

Migration from 0.1.x

The 0.1.x scripts under app/ (summarizer.py, translator.py, yt_summarizer.py, webui.py) are gone. Everything moved into the websum package with a typed, importable API.

Before After
python app/summarizer.py -u URL websum summarize URL
python app/webui.py websum ui
from summarizer import setup_summarization_chain from websum import Summarizer
Hardcoded ChatOllama OllamaBackend / OpenAIBackend / custom LLMBackend
pip install -r requirements.txt pip install 'websum[ollama]'

Development

git clone https://github.com/cobanov/websum
cd websum
uv sync --all-extras
uv run pre-commit install
uv run pytest
uv run ruff check .
uv run mypy src/websum

See CONTRIBUTING.md for the full guide.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

websum-0.2.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

websum-0.2.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file websum-0.2.0.tar.gz.

File metadata

  • Download URL: websum-0.2.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for websum-0.2.0.tar.gz
Algorithm Hash digest
SHA256 df527a9553c1f37012f85678fc3bfc89dbe3c7b6d6e60bbcc710eedb3b5c2b20
MD5 0b3f2cdadfed8dc11009f93e8abe95a2
BLAKE2b-256 688af7245642df724d08d4b584de7757da00a2a511aaaefe2a971f2e5d76d61f

See more details on using hashes here.

Provenance

The following attestation bundles were made for websum-0.2.0.tar.gz:

Publisher: release.yml on cobanov/websum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file websum-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: websum-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for websum-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46c23197d69a2ee457039d51575874b5171b2b8f12a187ae56f4ba024363cc7d
MD5 e6f644f5dd17c2f3370fdb9631fc153a
BLAKE2b-256 f303ff42ba931b2deedf031b381c43a37cd9d14c6b7617dc5ab43c9a09458404

See more details on using hashes here.

Provenance

The following attestation bundles were made for websum-0.2.0-py3-none-any.whl:

Publisher: release.yml on cobanov/websum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page