Client to interact with the Pythia API
Project description
pythia-client
This is the client make it easier to interact with our internal Pythia API.
This is still a work in progress
Usage
- Create a connection with client object
from pythia_client.client import APIClient
client = APIClient(url="http://localhost:8000", api_key="api-key")
- Query the knowledge base (ask a question)
filters = {
"operator": "AND",
"conditions": [
{
"field": "meta.source",
"operator": "==",
"value": "Salesforce",
},
],
}
query_response = client.query("Hey how are you", filters=filters)
query_response.model_dump()
- Index new files in the knowledge base
index_response = client.upload_files(["path/to/file.pdf"], meta=[{"source": "Salesforce"}])
index_response.model_dump()
# OR
index_response = client.upload_files([("file.pdf", file)], meta=[{"source": "Salesforce"}])
index_response.model_dump()
- List documents in the knowledge base (based on filters)
filters = {
"operator": "AND",
"conditions": [
{
"field": "meta.source",
"operator": "==",
"value": "Salesforce",
},
],
}
list_response = client.get_docs_by_filters(filters=filters)
list_response.model_dump()
- Remove documents from the knowledge base
filters = {
"operator": "AND",
"conditions": [
{
"field": "meta.source",
"operator": "==",
"value": "Salesforce",
},
],
}
remove_response = client.delete_docs_by_filters(filters=filters)
remove_response.model_dump()
- Get a presigned S3 url to the original document
get_doc_response = client.get_file_url("s3fd_sample.pdf", page=2)
s3_url = get_doc_response.url
- Extract JSON data from unstructured test.
Currently used to showcase the Email2Case feature.
extract_response = client.extract_structured_data("Hello I want to modify the delivery date of order FR73681920")
extract_response.model_dump()
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
pythia_client-0.2.1.tar.gz
(272.3 kB
view details)
Built Distribution
File details
Details for the file pythia_client-0.2.1.tar.gz
.
File metadata
- Download URL: pythia_client-0.2.1.tar.gz
- Upload date:
- Size: 272.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35889a2acac7a5a0672f2ba565fed6be78e457777f69745dd8026e5e635c8853 |
|
MD5 | 555bc474a45775379b211e905fa803f6 |
|
BLAKE2b-256 | 507ff6e2cd28e9c9925ebd1bab9cf40fb7761ccf3461bddc9c18fd4e0c30ff82 |
File details
Details for the file pythia_client-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: pythia_client-0.2.1-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5caa11f484e7274a8430943b899ffb3c1223a6fd4bfcf5b8d9c6a79b8abca981 |
|
MD5 | 2476c03ae8c6e670ca4deebf892b995c |
|
BLAKE2b-256 | 1be2e3999a7de6dd2e9ee65e8842f1671ce686b24c4ad7f49c1dae012bd75942 |