Metadata-Version: 2.2
Name: jsonllm-client
Version: 0.12.1
Summary: Client for JsonLLM API
Author-email: LocalTransformer team <info@localtransformer.com>
License: MIT License
        
        Copyright (c) 2024 microlib-org
        
        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: Homepage, https://github.com/microlib-org/jsonllm-client
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: tqdm
Requires-Dist: pydantic
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"

# JsonLLM client

`jsonllm-client` is a Python client library for interacting with the [JsonLLM API](https://jsonllm.com/).

JsonLLM allows you to extract structured data from documents.

`jsonllm-client` allows users to upload documents and delete documents, as well as extract data from said 
documents.

## Installation

`jsonllm-client` is available on PyPI, so it can be installed easily, e.g. using `pip`:

```bash
pip install jsonllm_client
```

## Initialization

You need to create an API key, which you can do [here](https://jsonllm.com/api-keys).

```python
from jsonllm_client import JsonLLM

api_key = "your_api_key_here"
json_llm = JsonLLM(api_key)

```


## Upload document(s)

To upload a document to a project, you need to use the `.upload` method:

```python
from jsonllm_client import JsonLLM

api_key = "your_api_key_here"
jsonllm = JsonLLM(api_key)

jsonllm.upload("invoice", "/home/ubuntu/Invoice_105274235.pdf")
```

To upload multiple documents, simply supply multiple paths:

```python
from jsonllm_client import JsonLLM

api_key = "your_api_key_here"
jsonllm = JsonLLM(api_key)

jsonllm.upload("invoice", ["/home/ubuntu/Invoice_13.pdf", "/home/ubuntu/Invoice_91.pdf"])
```


## Add plain text document(s)

To add a document from plain text, use the `.add_text` method:

```python
from jsonllm_client import JsonLLM

api_key = "your_api_key_here"
jsonllm = JsonLLM(api_key)

jsonllm.add_text("news", "cnn_article.txt", "Tensions rise.")
```

## Extract from document

```python
import json

from jsonllm_client import JsonLLM

api_key = "your_api_key_here"
jsonllm = JsonLLM(api_key)

res = jsonllm.extract(
    project="invoice",
    filename="Invoice_105274235.pdf"
)
print(json.dumps(res, indent=2))
# {
#   "invoice_date": "July 4, 2017",
#   "invoice_id": "105274235",
#   "s3_amount": "0.11",
#   "tax_amount": "0.00",
#   "total_amount": "52.57",
#   "vendor_name": "Amazon Web Services, Inc"
# }

```

## Delete document(s)

To delete a document, use the `.delete_document` method

```python
from jsonllm_client import JsonLLM

api_key = "your_api_key_here"
jsonllm = JsonLLM(api_key)

jsonllm.delete_document("invoice", "/home/ubuntu/Invoice_105274235.pdf")
```
