API for interacting with paperqa.app
Project description
paperqa-api
Python client for interacting with paperqa app
Usage
Make sure to set the environment variable PQA_API_TOKEN
or PQA_API_KEY
to your API token.
export PQA_API_TOKEN=pqa-...
To query agent:
import pqapi
response = pqapi.agent_query(
"Are COVID-19 vaccines effective?"
)
to query with a specific bibliography (collection of papers)
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:
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:
{% 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:
pqa-render template.jinja > output.md
Managing bibliographies
To get information about a specific bibliography
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:
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:
import pqapi
response = pqapi.delete_bibliography(
"default"
)
Development
You can change the server URL endpoint to a local PQA server with
export PQA_URL="http://localhost:8080"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pqapi-6.5.0.tar.gz
.
File metadata
- Download URL: pqapi-6.5.0.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 156b9e2f5bbd5ee0cd45c4c0b87ad8a9ed09b0beb86bff4c2cf96dd7d0ecd609 |
|
MD5 | 88fdd6975d74e34b3b010e8046c856e2 |
|
BLAKE2b-256 | 3c1521b834862f523f6062c04e6be1748ad106c92c47cd46f69e7a609070a403 |
File details
Details for the file pqapi-6.5.0-py3-none-any.whl
.
File metadata
- Download URL: pqapi-6.5.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07717000a9daf2b7be00d9bef19e2deb87240838a4b320552402aacc883514f7 |
|
MD5 | 2893387192e93031ea3de5995cc542ec |
|
BLAKE2b-256 | 136315f3419110cad66d3978f484531e62504d6feb55b2fe35232ef9a1e9a3ca |