Metadata-Version: 2.4
Name: pybrag
Version: 0.0.2
Summary: Basic RAG
Author-email: Arthur Lui <alui@lanl.gov>
License-Expression: MIT
Project-URL: Homepage, https://github.com/lanl/brag
Project-URL: Documentation, https://lanl.github.io/brag
Project-URL: Repository, https://github.com/lanl/brag
Project-URL: Issues, https://github.com/lanl/brag/issues
Project-URL: Changelog, https://github.com/lanl/brag/blob/master/CHANGELOG.md
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: gradio~=5.33.0
Requires-Dist: fastapi<0.116,>=0.115.7
Requires-Dist: langchain>=0.3.15
Requires-Dist: langchain-chroma>=0.2.4
Requires-Dist: langchain-community>=0.3.15
Requires-Dist: langchain-core>=0.3.31
Requires-Dist: langchain-litellm>=0.2.2
Requires-Dist: langchain-ollama>=0.3.4
Requires-Dist: langgraph>=0.5.3
Requires-Dist: docx2txt>=0.9
Requires-Dist: litellm==1.74.3
Requires-Dist: openai<2.0,>=1.60.1
Requires-Dist: pydantic<3.0,>=2.10.6
Requires-Dist: pymupdf4llm<0.1,>=0.0.17
Requires-Dist: pypdf<6.0,>=5.1.0
Requires-Dist: tqdm<5.0,>=4.67.1
Dynamic: license-file

# BRAG

[![PyPI Version][pypi-version]](https://pypi.org/project/pybrag/)
[![PyPI Downloads][pypi-downloads]](https://pypistats.org/packages/pybrag)

**B**asic **RAG** that can be used in a browser or command line.

## Installation
With pip:
```console
pip install pybrag
```

```console
# Test that brag was properly installed
brag --help
```

With uv:
```console
uv add pybrag
```

```
# Test that brag was properly installed
uv run brag --help
```

With uv, you can install brag as a tool by:
```console
uv tool install pybrag
```

```console
# 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`.)
```console
brag ask --corpus-dir path/to/my/corpus/of/documents
```

For more options
```console
brag ask --help
```

and
```
brag --help
```

If you want to run in a browser, set `port`.
```console
brag ask --corpus-dir path/to/my/corpus/of/documents --port=8000
```

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

## Advanced Usage
[LiteLLM](https://docs.litellm.ai/docs/) 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:

```console
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.,

```console
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`

## Development

The following development tools are not required, but recommended:
- `uv`
- `justfile`

You can install `uv` by following instructions from:
https://docs.astral.sh/uv/getting-started/installation/ I recommend using the
Standalone Installer.

After you install `uv`, you can install `just` by `uv tool install rust-justfile`.

[pypi-version]: https://img.shields.io/pypi/v/pybrag?style=flat-square&label=PyPI
[pypi-downloads]: https://img.shields.io/pypi/dm/pybrag?style=flat-square&label=Downloads&color=blue
