Metadata-Version: 2.1
Name: dff
Version: 0.6.3
Summary: [![Documentation Status](https://github.com/deeppavlov/dialog_flow_framework/workflows/build_and_publish_docs/badge.svg)](https://deeppavlov.github.io/dialog_flow_framework)
Home-page: https://github.com/deeppavlov/dialog_flow_framework
Author: Denis Kuznetsov
Author-email: kuznetsov.den.p@gmail.com
Keywords: chatbots
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.8, <4
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic <3.0,>=2.0.3
Requires-Dist: nest-asyncio
Requires-Dist: typing-extensions
Provides-Extra: benchmark
Requires-Dist: pympler ; extra == 'benchmark'
Requires-Dist: tqdm ; extra == 'benchmark'
Requires-Dist: humanize ; extra == 'benchmark'
Requires-Dist: pandas ; extra == 'benchmark'
Requires-Dist: altair ; extra == 'benchmark'
Requires-Dist: streamlit ; extra == 'benchmark'
Provides-Extra: core
Requires-Dist: pydantic <3.0,>=2.0.3 ; extra == 'core'
Requires-Dist: nest-asyncio ; extra == 'core'
Requires-Dist: typing-extensions ; extra == 'core'
Provides-Extra: devel
Requires-Dist: bump2version ==1.0.1 ; extra == 'devel'
Requires-Dist: build ==1.0.0 ; extra == 'devel'
Requires-Dist: twine ==4.0.0 ; extra == 'devel'
Provides-Extra: devel_full
Requires-Dist: sphinxcontrib-httpdomain ==1.8.0 ; extra == 'devel_full'
Requires-Dist: websockets ==11.0.2 ; extra == 'devel_full'
Requires-Dist: flake8 ==6.1.0 ; extra == 'devel_full'
Requires-Dist: jsonschema ==4.19.1 ; extra == 'devel_full'
Requires-Dist: pytelegrambotapi ; extra == 'devel_full'
Requires-Dist: pytest ==7.4.0 ; extra == 'devel_full'
Requires-Dist: sphinx-copybutton ==0.5.2 ; extra == 'devel_full'
Requires-Dist: click ==8.1.3 ; extra == 'devel_full'
Requires-Dist: aiochclient >=2.2.0 ; extra == 'devel_full'
Requires-Dist: telethon ==1.31.0 ; extra == 'devel_full'
Requires-Dist: pydantic <3.0,>=2.0.3 ; extra == 'devel_full'
Requires-Dist: streamlit ==1.27.0 ; extra == 'devel_full'
Requires-Dist: redis ; extra == 'devel_full'
Requires-Dist: requests ; extra == 'devel_full'
Requires-Dist: sphinxcontrib-katex ==0.9.0 ; extra == 'devel_full'
Requires-Dist: pytest-asyncio ==0.21.0 ; extra == 'devel_full'
Requires-Dist: ydb ; extra == 'devel_full'
Requires-Dist: tqdm ; extra == 'devel_full'
Requires-Dist: wrapt ; extra == 'devel_full'
Requires-Dist: black ==23.9.1 ; extra == 'devel_full'
Requires-Dist: psutil ==5.9.5 ; extra == 'devel_full'
Requires-Dist: sphinx-autodoc-typehints ==1.24.0 ; extra == 'devel_full'
Requires-Dist: locust ==2.17.0 ; extra == 'devel_full'
Requires-Dist: nbsphinx ==0.9.2 ; extra == 'devel_full'
Requires-Dist: jupytext ==1.15.0 ; extra == 'devel_full'
Requires-Dist: typing-extensions ; extra == 'devel_full'
Requires-Dist: sqlparse ==0.4.4 ; extra == 'devel_full'
Requires-Dist: fastapi ==0.103.1 ; extra == 'devel_full'
Requires-Dist: omegaconf ; extra == 'devel_full'
Requires-Dist: sphinx ==7.2.2 ; extra == 'devel_full'
Requires-Dist: asyncpg ; extra == 'devel_full'
Requires-Dist: opentelemetry-exporter-otlp >=1.20.0 ; extra == 'devel_full'
Requires-Dist: pympler ; extra == 'devel_full'
Requires-Dist: requests ==2.31.0 ; extra == 'devel_full'
Requires-Dist: sphinx-favicon ==1.0.1 ; extra == 'devel_full'
Requires-Dist: jupyter ==1.0.0 ; extra == 'devel_full'
Requires-Dist: pydata-sphinx-theme ==0.14.1 ; extra == 'devel_full'
Requires-Dist: cryptography ; extra == 'devel_full'
Requires-Dist: bump2version ==1.0.1 ; extra == 'devel_full'
Requires-Dist: pytest-virtualenv ==1.7.0 ; extra == 'devel_full'
Requires-Dist: isort ==5.12.0 ; extra == 'devel_full'
Requires-Dist: streamlit ; extra == 'devel_full'
Requires-Dist: sphinx-gallery ==0.14.0 ; extra == 'devel_full'
Requires-Dist: uvicorn ==0.23.1 ; extra == 'devel_full'
Requires-Dist: mypy ==1.6.0 ; extra == 'devel_full'
Requires-Dist: humanize ; extra == 'devel_full'
Requires-Dist: sphinxcontrib-apidoc ==0.4.0 ; extra == 'devel_full'
Requires-Dist: motor ; extra == 'devel_full'
Requires-Dist: build ==1.0.0 ; extra == 'devel_full'
Requires-Dist: pandas ; extra == 'devel_full'
Requires-Dist: aiosqlite ; extra == 'devel_full'
Requires-Dist: asyncmy ; extra == 'devel_full'
Requires-Dist: sqlalchemy[asyncio] ; extra == 'devel_full'
Requires-Dist: pytest-cov ==4.1.0 ; extra == 'devel_full'
Requires-Dist: flask[async] ==3.0.0 ; extra == 'devel_full'
Requires-Dist: nest-asyncio ; extra == 'devel_full'
Requires-Dist: six ; extra == 'devel_full'
Requires-Dist: altair ; extra == 'devel_full'
Requires-Dist: httpx <=0.23.0 ; extra == 'devel_full'
Requires-Dist: streamlit-chat ==0.1.1 ; extra == 'devel_full'
Requires-Dist: twine ==4.0.0 ; extra == 'devel_full'
Requires-Dist: opentelemetry-instrumentation ; extra == 'devel_full'
Requires-Dist: aiofiles ; extra == 'devel_full'
Provides-Extra: doc
Requires-Dist: sphinxcontrib-httpdomain ==1.8.0 ; extra == 'doc'
Requires-Dist: sphinx-favicon ==1.0.1 ; extra == 'doc'
Requires-Dist: jupyter ==1.0.0 ; extra == 'doc'
Requires-Dist: sphinx-autodoc-typehints ==1.24.0 ; extra == 'doc'
Requires-Dist: sphinx-gallery ==0.14.0 ; extra == 'doc'
Requires-Dist: nbsphinx ==0.9.2 ; extra == 'doc'
Requires-Dist: sphinx-copybutton ==0.5.2 ; extra == 'doc'
Requires-Dist: jupytext ==1.15.0 ; extra == 'doc'
Requires-Dist: sphinx ==7.2.2 ; extra == 'doc'
Requires-Dist: sphinxcontrib-apidoc ==0.4.0 ; extra == 'doc'
Requires-Dist: requests ==2.31.0 ; extra == 'doc'
Requires-Dist: sphinxcontrib-katex ==0.9.0 ; extra == 'doc'
Requires-Dist: pydata-sphinx-theme ==0.14.1 ; extra == 'doc'
Provides-Extra: full
Requires-Dist: pytelegrambotapi ; extra == 'full'
Requires-Dist: pydantic <3.0,>=2.0.3 ; extra == 'full'
Requires-Dist: requests ; extra == 'full'
Requires-Dist: redis ; extra == 'full'
Requires-Dist: ydb ; extra == 'full'
Requires-Dist: tqdm ; extra == 'full'
Requires-Dist: wrapt ; extra == 'full'
Requires-Dist: typing-extensions ; extra == 'full'
Requires-Dist: omegaconf ; extra == 'full'
Requires-Dist: asyncpg ; extra == 'full'
Requires-Dist: opentelemetry-exporter-otlp >=1.20.0 ; extra == 'full'
Requires-Dist: pympler ; extra == 'full'
Requires-Dist: cryptography ; extra == 'full'
Requires-Dist: streamlit ; extra == 'full'
Requires-Dist: humanize ; extra == 'full'
Requires-Dist: motor ; extra == 'full'
Requires-Dist: pandas ; extra == 'full'
Requires-Dist: aiosqlite ; extra == 'full'
Requires-Dist: asyncmy ; extra == 'full'
Requires-Dist: sqlalchemy[asyncio] ; extra == 'full'
Requires-Dist: nest-asyncio ; extra == 'full'
Requires-Dist: six ; extra == 'full'
Requires-Dist: altair ; extra == 'full'
Requires-Dist: opentelemetry-instrumentation ; extra == 'full'
Requires-Dist: aiofiles ; extra == 'full'
Provides-Extra: json
Requires-Dist: aiofiles ; extra == 'json'
Provides-Extra: mongodb
Requires-Dist: motor ; extra == 'mongodb'
Provides-Extra: mysql
Requires-Dist: sqlalchemy[asyncio] ; extra == 'mysql'
Requires-Dist: asyncmy ; extra == 'mysql'
Requires-Dist: cryptography ; extra == 'mysql'
Provides-Extra: pickle
Requires-Dist: aiofiles ; extra == 'pickle'
Provides-Extra: postgresql
Requires-Dist: sqlalchemy[asyncio] ; extra == 'postgresql'
Requires-Dist: asyncpg ; extra == 'postgresql'
Provides-Extra: redis
Requires-Dist: redis ; extra == 'redis'
Provides-Extra: sqlite
Requires-Dist: sqlalchemy[asyncio] ; extra == 'sqlite'
Requires-Dist: aiosqlite ; extra == 'sqlite'
Provides-Extra: stats
Requires-Dist: tqdm ; extra == 'stats'
Requires-Dist: wrapt ; extra == 'stats'
Requires-Dist: omegaconf ; extra == 'stats'
Requires-Dist: opentelemetry-exporter-otlp >=1.20.0 ; extra == 'stats'
Requires-Dist: requests ; extra == 'stats'
Requires-Dist: opentelemetry-instrumentation ; extra == 'stats'
Provides-Extra: telegram
Requires-Dist: pytelegrambotapi ; extra == 'telegram'
Provides-Extra: test_full
Requires-Dist: websockets ==11.0.2 ; extra == 'test_full'
Requires-Dist: flake8 ==6.1.0 ; extra == 'test_full'
Requires-Dist: jsonschema ==4.19.1 ; extra == 'test_full'
Requires-Dist: pytelegrambotapi ; extra == 'test_full'
Requires-Dist: pytest ==7.4.0 ; extra == 'test_full'
Requires-Dist: click ==8.1.3 ; extra == 'test_full'
Requires-Dist: aiochclient >=2.2.0 ; extra == 'test_full'
Requires-Dist: telethon ==1.31.0 ; extra == 'test_full'
Requires-Dist: pydantic <3.0,>=2.0.3 ; extra == 'test_full'
Requires-Dist: streamlit ==1.27.0 ; extra == 'test_full'
Requires-Dist: requests ; extra == 'test_full'
Requires-Dist: redis ; extra == 'test_full'
Requires-Dist: pytest-asyncio ==0.21.0 ; extra == 'test_full'
Requires-Dist: ydb ; extra == 'test_full'
Requires-Dist: tqdm ; extra == 'test_full'
Requires-Dist: opentelemetry-instrumentation ; extra == 'test_full'
Requires-Dist: wrapt ; extra == 'test_full'
Requires-Dist: black ==23.9.1 ; extra == 'test_full'
Requires-Dist: psutil ==5.9.5 ; extra == 'test_full'
Requires-Dist: locust ==2.17.0 ; extra == 'test_full'
Requires-Dist: typing-extensions ; extra == 'test_full'
Requires-Dist: sqlparse ==0.4.4 ; extra == 'test_full'
Requires-Dist: fastapi ==0.103.1 ; extra == 'test_full'
Requires-Dist: omegaconf ; extra == 'test_full'
Requires-Dist: asyncpg ; extra == 'test_full'
Requires-Dist: opentelemetry-exporter-otlp >=1.20.0 ; extra == 'test_full'
Requires-Dist: pympler ; extra == 'test_full'
Requires-Dist: requests ==2.31.0 ; extra == 'test_full'
Requires-Dist: cryptography ; extra == 'test_full'
Requires-Dist: pytest-virtualenv ==1.7.0 ; extra == 'test_full'
Requires-Dist: isort ==5.12.0 ; extra == 'test_full'
Requires-Dist: streamlit ; extra == 'test_full'
Requires-Dist: uvicorn ==0.23.1 ; extra == 'test_full'
Requires-Dist: humanize ; extra == 'test_full'
Requires-Dist: motor ; extra == 'test_full'
Requires-Dist: aiosqlite ; extra == 'test_full'
Requires-Dist: asyncmy ; extra == 'test_full'
Requires-Dist: sqlalchemy[asyncio] ; extra == 'test_full'
Requires-Dist: pytest-cov ==4.1.0 ; extra == 'test_full'
Requires-Dist: flask[async] ==3.0.0 ; extra == 'test_full'
Requires-Dist: nest-asyncio ; extra == 'test_full'
Requires-Dist: six ; extra == 'test_full'
Requires-Dist: altair ; extra == 'test_full'
Requires-Dist: httpx <=0.23.0 ; extra == 'test_full'
Requires-Dist: streamlit-chat ==0.1.1 ; extra == 'test_full'
Requires-Dist: pandas ; extra == 'test_full'
Requires-Dist: aiofiles ; extra == 'test_full'
Provides-Extra: tests
Requires-Dist: pytest-cov ==4.1.0 ; extra == 'tests'
Requires-Dist: pytest-virtualenv ==1.7.0 ; extra == 'tests'
Requires-Dist: flake8 ==6.1.0 ; extra == 'tests'
Requires-Dist: black ==23.9.1 ; extra == 'tests'
Requires-Dist: isort ==5.12.0 ; extra == 'tests'
Requires-Dist: pytest ==7.4.0 ; extra == 'tests'
Requires-Dist: jsonschema ==4.19.1 ; extra == 'tests'
Requires-Dist: sqlparse ==0.4.4 ; extra == 'tests'
Requires-Dist: click ==8.1.3 ; extra == 'tests'
Requires-Dist: aiochclient >=2.2.0 ; extra == 'tests'
Requires-Dist: httpx <=0.23.0 ; extra == 'tests'
Requires-Dist: requests ==2.31.0 ; extra == 'tests'
Requires-Dist: pytest-asyncio ==0.21.0 ; extra == 'tests'
Provides-Extra: ydb
Requires-Dist: ydb ; extra == 'ydb'
Requires-Dist: six ; extra == 'ydb'

# Dialog Flow Framework

[![Documentation Status](https://github.com/deeppavlov/dialog_flow_framework/workflows/build_and_publish_docs/badge.svg)](https://deeppavlov.github.io/dialog_flow_framework)
[![Codestyle](https://github.com/deeppavlov/dialog_flow_framework/workflows/codestyle/badge.svg)](https://github.com/deeppavlov/dialog_flow_framework/actions/workflows/codestyle.yml)
[![Tests](https://github.com/deeppavlov/dialog_flow_framework/workflows/test_coverage/badge.svg)](https://github.com/deeppavlov/dialog_flow_framework/actions/workflows/test_coverage.yml)
[![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/deeppavlov/dialog_flow_framework/blob/master/LICENSE)
![Python 3.8, 3.9, 3.10, 3.11](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-green.svg)
[![PyPI](https://img.shields.io/pypi/v/dff)](https://pypi.org/project/dff/)
[![Downloads](https://pepy.tech/badge/dff)](https://pepy.tech/project/dff)

The Dialog Flow Framework (DFF) allows you to develop conversational services.
DFF offers a specialized domain-specific language (DSL) for quickly writing dialogs in pure Python. The service is created by defining a special dialog graph that determines the behavior of the dialog agent. The latter is then leveraged in the DFF pipeline.
You can use the framework in various services such as social networks, call centers, websites, personal assistants, etc.

## Why choose DFF

* Written in pure Python, the framework is easily accessible for both beginners and experienced developers.
* For the same reason, all the abstractions used in DFF can be easily customized and extended using regular language synthax.
* DFF offers easy and straightforward tools for state management which is as easy as setting values of a Python dictionary.
* The framework is being actively maintained and thoroughly tested. The team is open to suggestions and quickly reacts to bug reports.

# Quick Start
## Installation

DFF can be installed via pip:

```bash
pip install dff
```

The above command will set the minimum dependencies to start working with DFF.
The installation process allows the user to choose from different packages based on their dependencies, which are:
```bash
pip install dff[json]  # dependencies for using JSON
pip install dff[pickle] # dependencies for using Pickle
pip install dff[redis]  # dependencies for using Redis
pip install dff[mongodb]  # dependencies for using MongoDB
pip install dff[mysql]  # dependencies for using MySQL
pip install dff[postgresql]  # dependencies for using PostgreSQL
pip install dff[sqlite]  # dependencies for using SQLite
pip install dff[ydb]  # dependencies for using Yandex Database
pip install dff[telegram]  # dependencies for using Telegram
pip install dff[benchmark]  # dependencies for benchmarking
```

For example, if you are going to use one of the database backends,
you can specify the corresponding requirements yourself. Multiple dependencies can be installed at once, e.g.
```bash
pip install dff[postgresql, mysql]
```

## Basic example

The following code snippet builds a simplistic chat bot that replies with messages
``Hi!`` and ``OK`` depending on user input, which only takes a few lines of code.
All the abstractions used in this example are thoroughly explained in the dedicated
[user guide](https://deeppavlov.github.io/dialog_flow_framework/user_guides/basic_conceptions.html).

```python
from dff.script import GLOBAL, TRANSITIONS, RESPONSE, Message
from dff.pipeline import Pipeline
import dff.script.conditions.std_conditions as cnd

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

# init pipeline
pipeline = Pipeline.from_script(script, start_label=("flow", "node_hi"))


def turn_handler(in_request: Message, pipeline: Pipeline) -> Message:
# Pass user request into pipeline and get dialog context (message history)
# The pipeline will automatically choose the correct response using script
ctx = pipeline(in_request, 0)
# Get last response from the context
out_response = ctx.last_response
return out_response


while True:
in_request = input("Your message: ")
out_response = turn_handler(Message(text=in_request), pipeline)
print("Response: ", out_response.text)
```

When you run this code, you get similar output:
```
Your message: hi
Response:  OK
Your message: Hi
Response:  Hi!
Your message: ok
Response:  OK
Your message: ok
Response:  OK
```

More advanced examples are available as a part of documentation:
[tutorials](https://deeppavlov.github.io/dialog_flow_framework/tutorials.html).

## Further steps

To further explore the API of the framework, you can make use of the [detailed documentation](https://deeppavlov.github.io/dialog_flow_framework/index.html).
Broken down into several sections to highlight all the aspects of development with DFF,
the documentation for the library is constantly available online.

# Contributing to the Dialog Flow Framework

We are open to accepting pull requests and bug reports.
Please refer to [CONTRIBUTING.md](https://github.com/deeppavlov/dialog_flow_framework/blob/master/CONTRIBUTING.md).

# License

DFF is distributed under the terms of the [Apache License 2.0](https://github.com/deeppavlov/dialog_flow_framework/blob/master/LICENSE).
