Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
- include information on context storages and interfaces
- add system requirements
- fix file references
- update instructions for testing and running bot with python
  • Loading branch information
RLKRo committed Oct 10, 2024
1 parent 007c5ea commit 0f4f7ae
Showing 1 changed file with 58 additions and 13 deletions.
71 changes: 58 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,27 @@

This repository is a template for Chatsky projects.

## How to use it
The bot presented here is fully-functional with a very simple script that should
be overwritten with yours (more on that in the next section).

### Clone the repo:
This bot uses SQLite to store dialog history. Refer to the [context storage tutorials](https://deeppavlov.github.io/chatsky/tutorials/index_context_storages.html)
if you'd like to use a different DB engine.

This bot uses Telegram as an interface. Refer to the [interface tutorials](https://deeppavlov.github.io/chatsky/tutorials/index_interfaces.html)
if you'd like to use different means of communicating.

## How to use

### [Step 0] System requirements

1. A unix system (e.g. Ubuntu 22.04) is recommended. Although both Chatsky and this template
support other systems such as Windows, the instructions below are for unix systems.
2. [Git](https://git-scm.com/downloads) to clone this repository.
3. |Option 1| [Docker Engine](https://docs.docker.com/engine/install/) and [Docker Compose](https://docs.docker.com/compose/install/)
if you want to run the bot inside a docker container.
4. |Option 2| [Python 3.9+](https://www.python.org/downloads/) if you don't want to use docker.

### [Step 1] Clone the repo

```shell
git clone https://github.com/deeppavlov/chatsky-template.git
Expand All @@ -15,33 +33,60 @@ Alternatively, you can create a new repository using this one as a template via

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

### Edit project files
### [Step 2] Edit project files

[0.] Install dependencies with
```shell
(cd services/bot && pip install -r requirements.txt)
```
1. Write your custom functions (e.g. custom responses, custom services) into `bot/custom`.
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)
1. Write your custom functions (e.g. custom responses, custom services) into `services/bot/bot/custom`.
2. Edit Chatsky script at `services/bot/bot/script.py`.
3. Save Telegram bot token into `secrets/tg_token.txt`.

### Test the bot
### [Step 3] Test the bot

#### With Python

First, move to the bot directory:

```shell
cd services/bot
```

Next, install project dependencies:

```shell
pip install -r requirements.txt
```

Finally, run tests:

```shell
(cd services/bot && pytest test.py)
pytest test.py
```

#### With Docker

```shell
docker build --target test services/bot
```

### Run the bot
### [Step 4] Run the bot

#### With Python

First, you need to be in the root directory of the project.

If you've done the previous step, run
```shell
cd ../..
```
to return from the `services/bot` directory.

Next, install project dependencies (if you haven't done so yet):

```shell
(cd services/bot && pip install -r requirements.txt)
```

Deploy the bot to telegram with:

```shell
(export DB_URI="sqlite+aiosqlite:////$(pwd)/sqlite.db" TG_BOT_TOKEN_FILE="$(pwd)/secrets/tg_token.txt" && cd services/bot && python app.py)
```
Expand Down

0 comments on commit 0f4f7ae

Please sign in to comment.