Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pqapi-6.6.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

pqapi-6.6.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pqapi-6.6.0.tar.gz.

File metadata

  • Download URL: pqapi-6.6.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

Hashes for pqapi-6.6.0.tar.gz
Algorithm Hash digest
SHA256 f76d417d178f8e1d7bfb8057d3489e4c81093aeb23c826a2b881ceec32f5f456
MD5 8fef58e8c87a09aa4a4dbb9e8490de76
BLAKE2b-256 2ce0b899dacbb18a1724670535af102d247db1c5ecdf95596490d64d42c1cc59

See more details on using hashes here.

File details

Details for the file pqapi-6.6.0-py3-none-any.whl.

File metadata

  • Download URL: pqapi-6.6.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pqapi-6.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fcc9c5c7b4c9d252233c98f8b9a95385f12b79801a837f7728c2fc082105feb4
MD5 cc7e79ba201ec32bed8082dd216dbcda
BLAKE2b-256 e28e074093ce05f4bfd6793aa21740c55b7b758c4bc57f674e35b4546ff7e8f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page