Metadata-Version: 2.5
Name: pageindex-search
Version: 0.1.1
Summary: Python client for Page Search API by PageIndex: find the pages of a PDF that answer your questions.
Project-URL: Homepage, https://search.pageindex.ai
Project-URL: Documentation, https://search.pageindex.ai/docs
Project-URL: Repository, https://github.com/VectifyAI/pageindex-search-python
Project-URL: Issues, https://github.com/VectifyAI/pageindex-search-python/issues
Author-email: PageIndex <support@pageindex.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: llm,pageindex,pdf,rag,retrieval,search
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Description-Content-Type: text/markdown

# pageindex-search

Python client for [Page Search API](https://search.pageindex.ai) by PageIndex. Upload a PDF, ask up to 10
questions at once, and get back the pages that answer each one, ranked by relevance. Every page is read.

```bash
pip install pageindex-search
```

Create an API key in the [console](https://search.pageindex.ai/console/keys) and set it:

```bash
export PAGEINDEX_SEARCH_API_KEY=pis_live_...
```

## Quick start

```python
from pageindex_search import PageSearch

client = PageSearch()

doc = client.upload("3M_2018_10K.pdf")
result = client.search(doc, ["What was capital expenditure in 2018?", "Who is the CEO?"])

for answer in result.results:
    print(answer.question)
    for page in answer.pages:
        print(f"  page {page.page}: {page.relevance:.2f}")

print(f"cost ${result.usage.cost_usd}, credit left ${result.usage.balance_usd}")
```

Upload a document once and search it as often as you like; uploading the same file again returns the same
document.

## Reference

| | |
| --- | --- |
| `PageSearch(api_key=None, base_url=None, timeout=120, max_retries=2)` | The key defaults to `PAGEINDEX_SEARCH_API_KEY`. |
| `upload(file, wait=True)` | A path, bytes or an open file. Returns a `Document`, ready to search unless `wait=False`. |
| `search(document, questions, top_k=None)` | Up to 10 questions. Each answer lists the pages likely to help (relevance 0.3 or more; 0.2 or more when fewer than 3 are; possibly none), or exactly `top_k`. |
| `document(id)`, `documents(limit, after)`, `iter_documents()` | Your documents. |
| `delete(document)` | Delete a document. |
| `usage(start=None, end=None)` | Uploads, searches and cost by day, your credit and stored pages. |

Errors raise `PageSearchError`, with the API's `status`, `code`, `message` and `request_id`.

See the [API reference](https://search.pageindex.ai/docs/api) for every field and the
[pricing](https://search.pageindex.ai/pricing).
