Metadata-Version: 2.1
Name: pqapi
Version: 6.6.0
Summary: API for interacting with paperqa.app
Author-email: Andrew White <andrew@futurehouse.org>
Maintainer-email: Andrew White <andrew@futurehouse.org>, James Braza <james@futurehouse.org>, Michael Skarlinski <mskarlinski@futurehouse.org>
License: MIT License
        
        Copyright (c) 2023 Future House
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: issues, https://github.com/Future-House/paperqa-api/issues
Project-URL: repository, https://github.com/Future-House/paperqa-api
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python
Requires-Python: >=3.11.0rc1
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohttp
Requires-Dist: paper-qa <5,>=4.1.1
Requires-Dist: pydantic ~=2.0
Requires-Dist: requests
Requires-Dist: tenacity

# 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.

```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"
)
```

# Development

You can change the server URL endpoint to a local PQA server with

```sh
export PQA_URL="http://localhost:8080"
```
