Skip to main content

This library starts a proxy for the cai server allowing for fulfillment hooks.

Project description

Logo

Ondewo Bpi

The BPI (Business Process Integration) Module

This module sits between the user and CAI:

                _______           _______
  ___          |       |         |       |
  NLU ==grpc==>|  BPI  |==grpc==>|  CAI  |
 |___|<==grpc==|       |<==grpc==|       |
               |_______|         |_______|

and has full access to the outgoing requests and the returning response. It also knows the location of CAI and has authorization, meaning it can edit the state of CAI directly with additional information.

A simple example of a server using the BPI looks like this:

import logging

from ondewo.nlu import session_pb2
from ondewo_bpi.bpi_server import BpiServer
import ondewo_bpi.helpers as helpers


class MyServer(BpiServer):
    def __init__(self) -> None:
        super().__init__()                        # initialize the server (parent class)
        self.register_handlers()                  # add handlerss for intents

    def register_handlers(self) -> None:          # the mapping from handled intents to functions
        self.register_handler(
            intent_name='i.my_handled_intent',    # a user-created intent
            handler=self.reformat_text_in_intent, # the function to handle it
        )
        self.register_handler(
            intent_name='Default Fallback Intent',  # a default (system created) intent
            handler=self.handle_default_fallback,   # the function to handle it
        )

    def reformat_text_in_intent(      # the handler functions take responses in an out, and can process parts of the response
        self, response: session_pb2.DetectIntentResponse
    ) -> session_pb2.DetectIntentResponse:
        return helpers.replace_text_in_response(
            search="<REPLACE:REPLACE_THIS_TEXT>",   # this entire pseudo-command would go in a text response for example
            replace="new text",
            response=response
        )

    def handle_default_fallback(      # the handler functions can also just trigger events and leave the response unchanged
        self, response: session_pb2.DetectIntentResponse
    ) -> session_pb2.DetectIntentResponse:
        logging.warning("Default fallback was triggered!")
        return response

There is a more complete example in ondewo_bpi/example/example.py which is hooked up to run via the Dockerfile (just do docker-compose up -d && docker-compose logs -f).

Have a look at the docker-compose file, and the sample.env. The port that the bpi listens on functionally replaces the cai port, so at the frontend you just have to point to a different port to use the bpi, there is no other difference. And the cai port will still be available as well, so switching between using CAI directly and using the BPI is just a matter of changing a single variable, the port.

CAI BPI
HOST=localhost:50055 HOST=localhost:50051

BPI QA

There is also an example server for integrating both CAI and the QA. It sends requests to both servers and returns the response that is most accurate.

BPI SIP

There is an example for integration with ONDEWO-VTSI (Voice Telephone System Integration), however the sip client submodule is not publicly available. Please request access to it to build telephone-system compantible BPI servers.

Project details


Download files

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

Source Distribution

ondewo-bpi-2.0.2.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ondewo_bpi-2.0.2-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file ondewo-bpi-2.0.2.tar.gz.

File metadata

  • Download URL: ondewo-bpi-2.0.2.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for ondewo-bpi-2.0.2.tar.gz
Algorithm Hash digest
SHA256 b89f5c8688aa5535665fb5eea4a761b31fc6d68e7f5ffd8d9fc7c2239404574a
MD5 503ec3490445df2c4740a8762f035c6a
BLAKE2b-256 cba1981bc6adce72539affc59a1376f99cfd824bb8efe4ceb96ee8ad5ce04d16

See more details on using hashes here.

File details

Details for the file ondewo_bpi-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: ondewo_bpi-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 31.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for ondewo_bpi-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 554ae43346dd1240d28363848c5fb2682c58fbeac51a64d84b443ca2c39da99d
MD5 271089f43233f6bdd66846902208208e
BLAKE2b-256 011a68f17594ed011d60c5cab6c43415512375be4fde050272339b98f3f6d519

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page