Skip to main content

BRAG

PyPI Version PyPI Downloads

Basic RAG that can be used in a browser or command line.

Installation

With pip:

pip install pybrag
# Test that brag was properly installed
brag --help

With uv:

uv add pybrag
# Test that brag was properly installed
uv run brag --help

With uv, you can install brag as a command line tool by:

uv tool install pybrag
# Test that brag was properly installed
brag --help

Usage

Ask questions, interactively, about a corpus of documents in a terminal. (Currently, the supported file types are pdf, txt, and md.)

brag ask --corpus-dir path/to/my/corpus/of/documents

For more options

brag ask --help

and

brag --help

If you want to run in a browser, set port.

brag ask --corpus-dir path/to/my/corpus/of/documents --port=8000

Then view the web app at http://localhost:8000.

Advanced Usage

LiteLLM is used to support the use of different LLM providers in brag. Models are specified as provider/model-id. For example, to use OpenAI's gpt-4o-mini, you can supply --llm=openai/gpt-4o-mini to brag ask. You can supply your openai api key via --api-key or set OPENAI_API_KEY in your shell.

With brag ask, you can use different providers for the language and embedding models. For example, say with brag ask you want to use as the LLM Llama-3.1-8b served via vllm, and nomic-embed-text as the embedding model served via ollama, you can run:

brag ask --corpus-dir <path-to-corpus> \
    --llm "hosted_vllm/meta-llama/Llama-3.1-8B-Instruct" \
    --emb "ollama/nomic-embed-text" \
    --base-url="http://localhost:8200"

This assumes that vllm is served on port 8200 on localhost and ollama is served at port 11434. You can also explicitly specify the port for ollama if served elsewhere. E.g.,

brag ask --corpus-dir <path-to-corpus> \
    --llm "hosted_vllm/meta-llama/Llama-3.1-8B-Instruct" \
    --emb "ollama/nomic-embed-text" \
    --base-url="http://localhost:8200"
    --emb-base-url="http://localhost:8201"

For all available options, run brag ask --help

Container Image

Brag images can be pulled as follows

Docker

docker pull ghcr.io/lanl/brag

Charliecloud

ch-image pull ghcr.io/lanl/brag

© 2025. Triad National Security, LLC. All rights reserved.

This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration. All rights in the program are reserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear Security Administration. The Government is granted for itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so.

LANL Software Release O4983

Metadata

Release files for pybrag 0.0.30

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pybrag 0.0.30
File Size Uploaded Provenance
pybrag-0.0.30.tar.gz 23.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pybrag 0.0.30
File Interpreter ABI Platform
pybrag-0.0.30-py3-none-any.whl Python 3 none any Details

Total release size: 48.8 kB

Release files / pybrag-0.0.30.tar.gz

Download URL pybrag-0.0.30.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4bcb44d727640b9b8eff012c043ee0070fad23feceafc89a9b9ddec89bf6dcad
BLAKE2b-256 checksum
How to use checksums
ff94c0a65705464f382ed39f64279f1a930663f9d5f405006e6d6de59166ad7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.20

Release files / pybrag-0.0.30-py3-none-any.whl

Download URL pybrag-0.0.30-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b707695d14e0ede520b72642606490e6e6e87b5451ebd12cfd1c4425bb0b5e4b
BLAKE2b-256 checksum
How to use checksums
5a9a469f7d5cc8b2bcb1c40b7ceb277164ce1d7296b14da39ee7bf87603a6d18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.5.20

Security for pybrag 0.0.30

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page