Stax.ai CX Service SDK
Project description
Stax.ai CX Service SDK
This project is created and maintained by Stax.ai, Inc.. This is proprietary to Stax.ai, Inc. Unauthorized use, copy, license, or modification of this project and all associated source code is strictly prohibited.
About
...coming soon...
Installation
pip install stax_cx_service_sdk
Usage
Write your service app
from os import getenv
from stax_cx_service_sdk import def_service
# This is the internal token for cross-internal system communication
@def_service(getenv('INTERNAL_KEY'))
def app(**kwargs):
'''
Your custom service.
- kwargs is a dictionary with arguments sent to the service.
Return an optional string representing the message to log.
If there is an error, raise an exception with a nice human-readable error message to show up on the log.
'''
# Put your service functionality here
# ...
# Raise an exception to report the error
raise Exception("Oops, something went wrong!")
# Return without an exception to complete
Testing your service
To test your automation, simply comment out the @def_service
line and call the app
function with the appropriate input arguments.
Deploy your service
- Navigate to the
Project CX
Google Cloud topic. - Create a Pub/Sub topic with the name:
service-{NAME}
, for exampleservice-generate-client-summary
. - Create a Cloud Function with the same name as the Pub/Sub topic.
- Set the trigger type to
Cloud Pub/Sub
. - Pick the previously created Pub/Sub topic.
- Select the appropriate memory, CPU, timeout, and concurrency settings.
- Select the
App Engine default service account
. - Add the runtime environment variable:
INTERNAL_KEY
. - Ensure your entry file is called
main.py
and that you have arequirements.txt
file with your dependencies. - Load your source code as a ZIP and configure the function appropriately (make sure the entry-point is set.)
- Test your function, and deploy it!
Using your service
In the API, use the auto
package to publish messages to the appropriate Pub/Sub topic created earlier to send a request to the service.
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
Built Distribution
File details
Details for the file stax_cx_service_sdk-0.0.1.tar.gz
.
File metadata
- Download URL: stax_cx_service_sdk-0.0.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb07f914307edd0756aeec72158ea7b1c126dbe858e87628d8a55497400c2a49 |
|
MD5 | 9a41c05f620f3783542c8c57872d7289 |
|
BLAKE2b-256 | 567380d763d93a00ad382864503f8203c93e90c0a8f0b3ef7faebd3c32d701b2 |
File details
Details for the file stax_cx_service_sdk-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: stax_cx_service_sdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1ecf7f8625cbd0ae493aee3f6e164d21557cacaff2a41ae0685f28c4b365f73 |
|
MD5 | 654a4330c5dfe2e5120259a36df1cfc0 |
|
BLAKE2b-256 | 984504cf6bd9ceaf5ddb4dfa4a8d7247f90d9003c68840a519d189e8704c4e41 |