Skip to content

Commit

Permalink
v0.8 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
RLKRo authored Jul 3, 2024
1 parent a89c3dd commit 5ffbe31
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# DFF Project Template
# Chatsky Project Template

This repository is a template for DFF projects.
This repository is a template for Chatsky projects.

## How to use it

### Clone the repo:

```shell
git clone https://github.com/deeppavlov/DFF-template.git
cd DFF-template
git clone https://github.com/deeppavlov/chatsky-template.git
cd chatsky-template
```

Alternatively, you can create a new repository using this one as a template via GitHub:

https://github.com/new?template_name=DFF-template&template_owner=deeppavlov
https://github.com/new?template_name=chatsky-template&template_owner=deeppavlov

### Edit project files

Expand All @@ -22,7 +22,7 @@ https://github.com/new?template_name=DFF-template&template_owner=deeppavlov
(cd services/bot && pip install -r requirements.txt)
```
1. Write your custom functions (e.g. custom responses, custom services) into `bot/custom`.
2. Edit DFF script at `bot/script.py`.
2. Edit Chatsky script at `bot/script.py`.
3. Save Telegram bot token into `secrets/tg_token.txt`. (currently this template only supports telegram bots)

### Test the bot
Expand Down
2 changes: 1 addition & 1 deletion services/bot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# syntax=docker/dockerfile:1
FROM python as base

WORKDIR /dff_pipeline
WORKDIR /chatsky_pipeline

COPY requirements.txt requirements.txt
RUN ["python", "-m", "pip", "install", "-r", "requirements.txt"]
Expand Down
2 changes: 1 addition & 1 deletion services/bot/bot/custom/conditions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dff.script import Context
from chatsky.script import Context


def is_upper_case(ctx: Context, pipeline):
Expand Down
8 changes: 4 additions & 4 deletions services/bot/bot/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from dff.pipeline import Pipeline
from dff.context_storages import context_storage_factory
from dff.messengers.telegram import PollingTelegramInterface
from chatsky.pipeline import Pipeline
from chatsky.context_storages import context_storage_factory
from chatsky.messengers.telegram import LongpollingInterface

from . import script

Expand All @@ -24,7 +24,7 @@ def get_variable(var_name: str):
messenger_interface = None

if TG_BOT_TOKEN is not None:
messenger_interface = PollingTelegramInterface(token=TG_BOT_TOKEN)
messenger_interface = LongpollingInterface(token=TG_BOT_TOKEN)


pipeline = Pipeline.from_script(
Expand Down
8 changes: 4 additions & 4 deletions services/bot/bot/script.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dff.script import Message
from dff.script import RESPONSE, TRANSITIONS, LOCAL
from dff.script.conditions import exact_match, true
from chatsky.script import Message
from chatsky.script import RESPONSE, TRANSITIONS, LOCAL
from chatsky.script.conditions import exact_match, true

from .custom.conditions import is_upper_case
from .custom.services import pre_service, post_service
Expand All @@ -11,7 +11,7 @@
"technical_flow": {
"start_node": {
TRANSITIONS: {
("main_flow", "greeting_node"): exact_match(Message("/start")),
("main_flow", "greeting_node"): exact_match("/start"),
},
},
"fallback": {
Expand Down
2 changes: 1 addition & 1 deletion services/bot/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dff[telegram,sqlite]~=0.7
chatsky[telegram,sqlite]~=0.8
pytest
5 changes: 2 additions & 3 deletions services/bot/test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from json import load
from pathlib import Path

from dff.utils.testing import check_happy_path
from dff.script import Message
from chatsky.utils.testing import check_happy_path
import pytest

from .bot.pipeline import pipeline
Expand All @@ -22,4 +21,4 @@
"happy_path", TEST_CASES
)
def test_happy_paths(happy_path: str):
check_happy_path(pipeline, tuple(map(lambda l: (Message(text=l[0]), Message(text=l[1])), TEST_DATA[happy_path])))
check_happy_path(pipeline, TEST_DATA[happy_path])

0 comments on commit 5ffbe31

Please sign in to comment.