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.3.tar.gz
(288.3 kB
view details)
Built Distribution
File details
Details for the file pythia_client-0.4.3.tar.gz
.
File metadata
- Download URL: pythia_client-0.4.3.tar.gz
- Upload date:
- Size: 288.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d3b62b8ea304009263b982db14bf751dbf719e3e8a591df857ab305249c81b8 |
|
MD5 | 430a46f0272424ab523cf73d2b92c4d4 |
|
BLAKE2b-256 | f92b193a3bd18e8cae219a688ec6a78e0251c1cc2ff81cba18cccfd230117f98 |
File details
Details for the file pythia_client-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: pythia_client-0.4.3-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.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c09807a2c61ea91a47757990d4f434334a218ed9aae69d4c887e57b1e8433c3b |
|
MD5 | 24b7f36f66dadd0b97fa28ae65b6be76 |
|
BLAKE2b-256 | b989f86b70f89a9a8cd6db64c0d7216e2ded6a5bbd0808b800b7faff93c3b170 |