Skip to main content

ServisBOT SDK for Data Science

Project description

py-sb-sdk

Prerequisites

  • Python 3.7

SbAuth

The SbAuth class is used to encapsulate the signing of requests for specific resources. You must export your AWS credentials to allow the SDK to sign requests:

export AWS_ACCESS_KEY_ID="key_id"
export AWS_SECRET_ACCESS_KEY="access_key"
export AWS_SESSION_TOKEN="token"

SbAuth will attempt to configure the AWS Region by looking checking the following values in this order:

  • aws_region passed to the constructor of SbAuth through the named argument aws_region.
  • AWS_DEFAULT_REGION in your environment variables
  • AWS_REGION in your environment variables
  • Checks to see if boto3 has found a region by checking the local aws config file, or possibly through an AWS client that is being used during the boto session. If SbAuth can not set an AWS Region an Exception is thrown.

To initialize an SbAuth object you can do the following:

from servisbotsdk import SbAuth
org = "flowit"
sb_auth = SbAuth(org, broca_url="https://broca.testdomain.test")

If you need to override the AWS region you can pass it as an argument to the constructor

from servisbotsdk import SbAuth
org = "flowit"
sb_auth = SbAuth(org, broca_url="https://broca.testdomain.test", aws_region="eu-west-1")

Intent

Describe

Code Snippet

from servisbotsdk import SbAuth, Intent
org = "flowit"
sb_auth = SbAuth(
    org,
    broca_url="https://broca.testdomain.test",
)
intent = Intent(sb_auth)
describe_resp = intent.describe("bot-name", "alias")

Response

{
  'alias': 'alias',
  'displayName': 'pricing',
  'bot': 'bot-name',
  'version': '$LATEST',
  'utterances': [{
    'text': 'What is the price of a large coffee',
    'enabled': True
  }],
  'fulfilment': {
    'actions': '[]'
  },
  'detection': {
    'actions': '[]'
  },
  'scope': None,
  'slots': []
}

List

Code Snippet

from servisbotsdk import SbAuth, Intent
org = "flowit"
sb_auth = SbAuth(
    org,
    broca_url="https://broca.testdomain.test",
)
intent = Intent(sb_auth)

resp = intent.list("DeanBIDF", {"limit": 1})

second_page = intent.list("bot-name", {"nextToken": resp["nextToken"], "limit": 1})

Response

{
  'intents': [{
    'alias': 'sizing',
    'displayName': 'sizing',
    'bot': 'botname',
    'version': '$LATEST',
    'utterances': [{
      'text': 'how much caffeine is in a large coffee',
      'enabled': True
    }, {
      'text': 'why is a flat white so small',
      'enabled': True
    }, {
      'text': 'why are medium coffees not large coffees',
      'enabled': True
    }],
    'fulfilment': {
      'actions': '[{"type":"message","value":"some value"}]'
    },
    'detection': {
      'actions': '[]'
    },
    'scope': None
  }],
  'nextToken': 'some-token'
}

Pagination

Some resources allow you to iterate through the resource using a paginator. The arguments passed to the paginator will vary depending on the resource. An example of pagination be found below:

from servisbotsdk import SbAuth, Intent
org = "flowit"
sb_auth = SbAuth(
    org,
    broca_url="https://broca.testdomain.test",
)
intent = Intent(sb_auth)
for intents in intent.paginator("DeanBIDF", {"limit": 1}):
    for intent in intents:
        print(intent)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for servisbotsdk, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size servisbotsdk-0.1.1-py3-none-any.whl (5.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size servisbotsdk-0.1.1.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page