Skip to main content

The Dialog Flow Engine (DFE) allows you to write conversational services. The service is written by defining a special dialog graph that describes the behavior of the dialog service. The dialog graph contains the dialog script. DFE offers a specialized language (DSL) for quickly writing dialog graphs. You can use it in such services for writing skills for Amazon Alexa and etc, chat-bots for social networks, websites call-centers and etc.

Project description

Dialog Flow Engine

The Dialog Flow Engine (DFE) allows you to write conversational services. The service is written by defining a special dialog graph that describes the behavior of the dialog service. The dialog graph contains the dialog script. DFE offers a specialized language (DSL) for quickly writing dialog graphs. You can use it in such services for writing skills for Amazon Alexa and etc, chat-bots for social networks, websites call-centers and etc.

Documentation Status Codestyle Tests License Apache 2.0 Python 3.6, 3.7, 3.8, 3.9 PyPI Downloads

Quick Start

Installation

pip install df_engine

Basic example

from df_engine.core.keywords import GLOBAL, TRANSITIONS, RESPONSE
from df_engine.core import Context, Actor
import df_engine.conditions as cnd
from typing import Union

# create script of dialog
script = {
GLOBAL: {TRANSITIONS: {("flow", "node_hi"): cnd.exact_match("Hi"), ("flow", "node_ok"): cnd.true()}},
"flow": {
"node_hi": {RESPONSE: "Hi!!!"},
"node_ok": {RESPONSE: "Okey"},
},
}

# init actor
actor = Actor(script, start_label=("flow", "node_hi"))


# handler requests
def turn_handler(in_request: str, ctx: Union[Context, dict], actor: Actor):
# Context.cast - gets an object type of [Context, str, dict] returns an object type of Context
ctx = Context.cast(ctx)
# Add in current context a next request of user
ctx.add_request(in_request)
# pass the context into actor and it returns updated context with actor response
ctx = actor(ctx)
# get last actor response from the context
out_response = ctx.last_response
# the next condition branching needs for testing
return out_response, ctx


ctx = {}
while True:
in_request = input("type your answer: ")
out_response, ctx = turn_handler(in_request, ctx, actor)
print(out_response)

When you run this code, you get similar output:

type your answer: hi
Okey
type your answer: Hi
Hi!!!
type your answer: ok
Okey
type your answer: ok
Okey

To get more advanced examples, take a look at examples on GitHub.

Contributing to the Dialog Flow Engine

Please refer to CONTRIBUTING.md.

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

df_engine-0.9.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

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

df_engine-0.9.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file df_engine-0.9.0.tar.gz.

File metadata

  • Download URL: df_engine-0.9.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for df_engine-0.9.0.tar.gz
Algorithm Hash digest
SHA256 a416769456e2e08bfb330ccc6f8fbfdcfda56573971352585024168613eaa677
MD5 0f601d806ff4055ed2403f5e9a03ba64
BLAKE2b-256 b0763bf152ef78ca0ce3ef21b0b9e45d65a12c081c2df51f9d7b45a916a39738

See more details on using hashes here.

File details

Details for the file df_engine-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: df_engine-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for df_engine-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43dcdb0d55c97389e2042a5208e61251b3f31c0e43ec174b6753c954adbad7ac
MD5 1bc0699c1ce046b95a4606994177fdbd
BLAKE2b-256 1d97fd3babf3218cc20aec16e99bc040c8025675e1920c77b091b0d7dc8575cf

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