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.
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.
Metadata
Release files for df-engine 0.10.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| df_engine-0.10.1.tar.gz | 22.9 kB | Without provenance | Details for df_engine-0.10.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| df_engine-0.10.1-py3-none-any.whl | Python 3 | none | any | Details for df_engine-0.10.1-py3-none-any.whl |
Total release size: 54.4 kB
Release files / df_engine-0.10.1.tar.gz
| Download URL | df_engine-0.10.1.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2371528c17098a03be5745bee7f6d982de27ebe0234e607c7d9fd90e0cb01d5d
|
|
BLAKE2b-256 checksum How to use checksums |
78451e2b15806002d4fcd0a7ebb49936aaa087c6de6ec2d50c209b6dce11de68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / df_engine-0.10.1-py3-none-any.whl
| Download URL | df_engine-0.10.1-py3-none-any.whl |
|---|---|
| Size | 31.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a6927f2e574904686d36bf3c2869bb2b101c126b2196f55fe7100ec6eeeb8e1
|
|
BLAKE2b-256 checksum How to use checksums |
de52c80e22e92d6616045a114b7951f6b45e0ec4561794052e2c786d223eb10b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for df-engine 0.10.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.