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.4.2.tar.gz
(288.3 kB
view details)
Built Distribution
File details
Details for the file pythia_client-0.4.2.tar.gz
.
File metadata
- Download URL: pythia_client-0.4.2.tar.gz
- Upload date:
- Size: 288.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62bdde5bb86a94c7660a6d85a68643cf243605ce5ea51d687906fed9bd7a8214 |
|
MD5 | 5519aa44e0138741ac705f8dfcdf95f6 |
|
BLAKE2b-256 | 079ad4f30b6a5ea5ef175da0a91526969273f255f0ce86cd770d77d80f995b58 |
File details
Details for the file pythia_client-0.4.2-py3-none-any.whl
.
File metadata
- Download URL: pythia_client-0.4.2-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6973c8e5de97d210fde59fe4d8da846ab2db9ed6ca814747f59b1ee095027e52 |
|
MD5 | 07c7cf87f4b2b36ff86c0f296b680b29 |
|
BLAKE2b-256 | 87915b4cc084902cda39635ed829b34f5d3efcefa312b7facac13fa61cb416f9 |