Skip to main content

Basic RAG

Project description

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

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

pybrag-0.0.29.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

pybrag-0.0.29-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file pybrag-0.0.29.tar.gz.

File metadata

  • Download URL: pybrag-0.0.29.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.20

File hashes

Hashes for pybrag-0.0.29.tar.gz
Algorithm Hash digest
SHA256 6f750cafd100d1e764f2f7a168053127f25fa16e60a24a76c37728abf390229c
MD5 54b8b78dc5ee0cb8c62af325af6c6502
BLAKE2b-256 435e03ff4ea4b2e0bdd8cc2486e0eabf1c067201a2bb5778dc2118e785690752

See more details on using hashes here.

File details

Details for the file pybrag-0.0.29-py3-none-any.whl.

File metadata

  • Download URL: pybrag-0.0.29-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.20

File hashes

Hashes for pybrag-0.0.29-py3-none-any.whl
Algorithm Hash digest
SHA256 82cf3bc773a8daad825277c9b5afd86bfc915f13335960d6b56e24579917e3c8
MD5 c11e64a2a69df0232318ec5e9fa9816e
BLAKE2b-256 113e02db52f60884accbabb7f2c8f7e5bc915f074e9cbe3d1dc251c0607be168

See more details on using hashes here.

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