> For the complete documentation index, see [llms.txt](https://docs.edisonscientific.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.edisonscientific.com/paperqa/contributing.md).

# Contributing to PaperQA

Thank you for your interest in contributing to PaperQA! Here are some guidelines to help you get started.

## Setting up the development environment

We use [`uv`](https://github.com/astral-sh/uv) for our local development.

1. Install `uv` by following the instructions on the [uv website](https://astral.sh/uv/).
2. Run the following command to install all dependencies and set up the development environment:

   ```bash
   uv sync
   ```

## Installing the package for development

If you prefer to use `pip` for installing the package in development mode, you can do so by running:

```bash
pip install -e ".[dev]"
```

Where the `dev` extra includes development dependencies such as `pytest`.

## Running tests and other tooling

Use the following commands:

* Run the same credential-free tests as CI:

  ```bash
  LITELLM_LOCAL_MODEL_COST_MAP=true PQA_OFFLINE_TESTS=true \
    pytest -m 'offline and not live_api'
  ```

  This mode uses local fixtures and VCR cassettes, supplies placeholder API keys, and disables cassette recording. Tests marked `live_api` need provider credentials and are excluded from CI.
* Run all tests, including live API tests (requires provider keys):

  ```bash
  pytest
  # or for multiprocessing based parallelism
  pytest -n auto
  ```
* Run `pre-commit` for formatting and type checking

  ```bash
  pre-commit run --all-files
  ```
* Run `ty` or `pylint` directly:

  ```bash
  ty check
  # or
  pylint paperqa
  ```

See our GitHub Actions [`tests.yml`](https://github.com/Future-House/paper-qa/tree/main/.github/workflows/tests.yml) for further reference.

## Using `pytest-recording` and VCR cassettes

We use the [`pytest-recording`](https://github.com/kiwicom/pytest-recording) plugin to create VCR cassettes to cache HTTP requests, making our unit tests more deterministic.

To record a new VCR cassette:

```bash
uv run pytest --record-mode=once tests/desired_test_module.py
```

And the new cassette(s) should appear in [`tests/cassettes`](https://github.com/Future-House/paper-qa/tree/main/tests/cassettes/README.md). Use `--record-mode=all` to refresh an existing cassette after model changes.

Our configuration for `pytest-recording` can be found in [`tests/conftest.py`](https://github.com/Future-House/paper-qa/tree/main/tests/conftest.py). This includes header removals (e.g. OpenAI `authorization` key) from responses to ensure sensitive information is excluded from the cassettes.

Keep cassettes small where possible. Media requests and tokenizer data can make some recorded files larger than 1 MB.

Happy coding!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.edisonscientific.com/paperqa/contributing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
