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.10.1.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

df_engine-0.10.1-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: df_engine-0.10.1.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for df_engine-0.10.1.tar.gz
Algorithm Hash digest
SHA256 2371528c17098a03be5745bee7f6d982de27ebe0234e607c7d9fd90e0cb01d5d
MD5 d42a0380b26f5d48ac0e5552145de03d
BLAKE2b-256 78451e2b15806002d4fcd0a7ebb49936aaa087c6de6ec2d50c209b6dce11de68

See more details on using hashes here.

File details

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

File metadata

  • Download URL: df_engine-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for df_engine-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a6927f2e574904686d36bf3c2869bb2b101c126b2196f55fe7100ec6eeeb8e1
MD5 e0987e00478484e1ffaa6ed356719363
BLAKE2b-256 de52c80e22e92d6616045a114b7951f6b45e0ec4561794052e2c786d223eb10b

See more details on using hashes here.

Supported by

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