Metadata-Version: 2.1
Name: pqapi
Version: 3.0.0
Summary: API for interacting with paperqa.app
Home-page: https://github.com/Future-House/pqapi
Author: Andrew White
Author-email: andrew@futurehouse.org
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: pydantic
Requires-Dist: paper-qa
Requires-Dist: tenacity
Requires-Dist: aiohttp
Requires-Dist: jinja2

# peperqa-api
Python UI for interacting with paperqa app

# Usage

Make sure to set the environment variable `PQA_API_TOKEN` to your API token.

```sh
export PQA_API_TOKEN=pqa-...
```

To query agent:

```py
import pqapi
response = pqapi.agent_query(
    "Are COVID-19 vaccines effective?"
)
```

to query with a specific bibliography (collection of papers)
```py
import pqapi
response = pqapi.agent_query(
    "Are COVID-19 vaccines effective?",
    "covid"
)
```

## Templates

You can use templates to batch multiple queries together. A minimal example would be:

```jinja
The effectiveness of COVID-19 is given below:
{{ "Are COVID-19 vaccines effective?" | pqa}}
```

Or, more complex examples can use shared bibliographies set by variables names:
```jinja
{% with bib = "covid" %}
## Info
{{ "Are COVID-19 vaccines effective?" | pqa(bib)}}

## Modality
{{ "Has there been an AAV COVID-19 vaccine?" | pqa(bib)}}
{% endwith %}
```

You render it via:

```sh
pqa-render template.jinja > output.md
```


## Managing bibliographies


To get information about a specific bibliography

```py
import pqapi
response = pqapi.get_bibliography(
    "default"
)
print(response)
```

You do not need to explicitly create a bibliography, just adding files will create one. To upload files:

```py
import pqapi
files = open("paper.pdf", "rb")
metadata =
    pqapi.UploadMetadata(filename="paper.pdf", citation="Test Citation")

response = pqapi.upload_file(
    "default",
    file
    metadata
)
```

To delete a bibliography:

```py
import pqapi
response = pqapi.delete_bibliography(
    "default"
)
```
