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"}], indexing_mode="unstructured")
index_response.model_dump()
# OR
index_response = client.upload_files([("file.pdf", file)], meta=[{"source": "Salesforce"}], indexing_mode="unstructured")
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.1.9.tar.gz
(271.5 kB
view details)
Built Distribution
File details
Details for the file pythia_client-0.1.9.tar.gz
.
File metadata
- Download URL: pythia_client-0.1.9.tar.gz
- Upload date:
- Size: 271.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cb768c83bc29909a490de3153196f3206a7f04f9b341da0b98858f50021dc24 |
|
MD5 | 39afed0dc6259957dc61760fe5af9278 |
|
BLAKE2b-256 | c70f8deb1770ea2ccf53bf4239d63a394e1e11654a0bcbfac4fb3dd3c294c178 |
File details
Details for the file pythia_client-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: pythia_client-0.1.9-py3-none-any.whl
- Upload date:
- Size: 11.9 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 | 89753185dbbf6b151cc723320346194360ee92d304655d9e7972dd73ae62744b |
|
MD5 | 79a9218b34400435379b6f464018330b |
|
BLAKE2b-256 | 4f8fbbd042b3a787908e43e1fd47024414c34c47f759a42a31fd14f19d3e2daa |