Chatsky allows you to develop conversational services. Chatsky 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 Chatsky pipeline. You can use the framework in various services such as social networks, call centers, websites, personal assistants, etc.
Chatsky, a versatile Python-based conversational service framework, can be deployed across a spectrum of platforms, ensuring flexibility for both novice and seasoned developers:
Whether deployed on cloud platforms, containerized environments, or directly on IoT devices, Chatsky's accessibility and customization options make it a robust choice for developing conversational services in the evolving landscape of Python applications and IoT connectivity.
Chatsky can be installed via pip:
pip install chatsky
The above command will set the minimum dependencies to start working with Chatsky. The installation process allows the user to choose from different packages based on their dependencies, which are:
pip install chatsky[json] # dependencies for using JSON
pip install chatsky[pickle] # dependencies for using Pickle
pip install chatsky[redis] # dependencies for using Redis
pip install chatsky[mongodb] # dependencies for using MongoDB
pip install chatsky[mysql] # dependencies for using MySQL
pip install chatsky[postgresql] # dependencies for using PostgreSQL
pip install chatsky[sqlite] # dependencies for using SQLite
pip install chatsky[ydb] # dependencies for using Yandex Database
pip install chatsky[telegram] # dependencies for using Telegram
pip install chatsky[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.
pip install chatsky[postgresql,mysql]
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.
from chatsky import (
GLOBAL,
TRANSITIONS,
RESPONSE,
Pipeline,
conditions as cnd,
Transition as Tr,
)
# create a dialog script
script = {
GLOBAL: {
TRANSITIONS: [
Tr(
dst=("flow", "node_hi"),
cnd=cnd.ExactMatch("Hi"),
),
Tr(
dst=("flow", "node_ok")
)
]
},
"flow": {
"node_hi": {RESPONSE: "Hi!"},
"node_ok": {RESPONSE: "OK"},
},
}
# initialize Pipeline (needed to run the script)
pipeline = Pipeline(script, start_label=("flow", "node_hi"))
pipeline.run()
When you run this code, you get similar output:
request: hi
response: text='OK'
request: Hi
response: text='Hi!'
More advanced examples are available as a part of documentation: tutorials.
To further explore the API of the framework, you can make use of the detailed documentation. Broken down into several sections to highlight all the aspects of development with Chatsky, the documentation for the library is constantly available online.
We are open to accepting pull requests and bug reports. Please refer to CONTRIBUTING.md.
Chatsky is distributed under the terms of the Apache License 2.0.