Skip to content

Commit

Permalink
docker fixes for hydra configuration poc (#34)
Browse files Browse the repository at this point in the history
* docker fixes hydra configuration poc

* fix agent installation

* fix dp-agent commit in dockerfile_agent

* Fix requirements.txt (#84)

* update pr against the new main branch

* fix itsdangerous requirements

* pin itsdangerous requirements for all flask==1.1.1 servers

* minimal reproducible example for new dream

* add pem files to gitignore, small agent docker fix

* change commit, remove copy settings

* fix agent command in base compose file

* fix agent installation

* fix agent command in other dists

* fix commands in readme, add telegram section

* update en and ru readme

Co-authored-by: Andrii.Hura <54397922+AndriiHura@users.noreply.github.com>
Co-authored-by: Dilyara Baymurzina <dilyara.rimovna@gmail.com>
  • Loading branch information
3 people committed Aug 24, 2022
1 parent fd9f40f commit 0304479
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,5 @@ network.yml

kubernetes/models
docker-compose-one-replica.yml

*.pem
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,32 @@ AGENT_PORT=4242 docker-compose -f docker-compose.yml -f assistant_dists/dream/do
```

### Let's chat

DeepPavlov Agent provides several options for interaction: a command line interface, an HTTP API, and a Telegram bot

#### CLI
In a separate terminal tab run:

```
docker-compose exec agent python -m deeppavlov_agent.run -pl assistant_dists/dream/pipeline_conf.json
docker-compose exec agent python -m deeppavlov_agent.run agent.channel=cmd agent.pipeline_config=assistant_dists/dream/pipeline_conf.json
```

Enter your username and have a chat with Dream!

#### HTTP API
Once you've started the bot, DeepPavlov's Agent API will run on `http://localhost:4242`.
You can learn about the API from the [DeepPavlov Agent Docs](https://deeppavlov-agent.readthedocs.io/en/latest/intro/overview.html#http-api-server).

A basic chat interface will be available at `http://localhost:4242/chat`.

### Let's talk via HTTP API
Once you've started the bot, DeepPavlov's Agent API will run on `http://localhost:4242'. You can learn about its API from the [DeepPavlov Agent Docs](https://deeppavlov-agent.readthedocs.io/en/latest/intro/overview.html#http-api-server).
#### Telegram Bot
Currently, Telegram bot is deployed **instead** of HTTP API.
Edit `agent` `command` definition inside `docker-compose.override.yml` config:
```
agent:
command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.channel=telegram agent.telegram_token=<TELEGRAM_BOT_TOKEN> agent.pipeline_config=assistant_dists/dream/pipeline_conf.json'
```
**NOTE:** treat your Telegram token as a secret and do not commit it to public repositories!

# Configuration and proxy usage
Dream uses several docker-compose configuration files:
Expand Down
27 changes: 20 additions & 7 deletions README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,32 @@ AGENT_PORT=4242 docker-compose -f docker-compose.yml -f assistant_dists/dream/do
```

### Использование
В отдельном вкладке терминала запустите:

DeepPavlov Agent предоставляет 3 варианта взаимодействия: через интерфейс командной строки, API и Телеграм-бот

#### CLI
В отдельной вкладке терминала запустите:

```
docker-compose exec agent python -m deeppavlov_agent.run -pl assistant_dists/dream/pipeline_conf.json
docker-compose exec agent python -m deeppavlov_agent.run agent.channel=cmd agent.pipeline_config=assistant_dists/dream/pipeline_conf.json
```

Введите имя пользователя и можете начать болтать с Dream!
Введите имя пользователя и можете начать общаться с Dream!

#### HTTP API
Как только вы подняли бота, Agent API станет доступен по адресу `http://localhost:4242`.
Узнать больше про API можно в [DeepPavlov Agent Docs](https://deeppavlov-agent.readthedocs.io/en/latest/intro/overview.html#http-api-server).

Браузерный интерфейс чата в DeepPavlov Agent доступен по адресу `http://localhost:4242/chat'.

### Использование с HTTP API
Как только вы подняли бота, DeepPavlov's Agent API запускает `http://localhost:4242'.
Брайзерный интерфейс по умолчанию в DeepPavlov Agent доступен как `http://localhost:4242/chat'.
Узнать больше про API можно в [DeepPavlov Agent Docs](https://deeppavlov-agent.readthedocs.io/en/latest/intro/overview.html#http-api-server).
#### Telegram Bot
На данный момент Телеграм-бот разворачивается **вместо** HTTP API
Измените определение `agent` `command` внутри `docker-compose.override.yml`:
```
agent:
command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.channel=telegram agent.telegram_token=<TELEGRAM_BOT_TOKEN> agent.pipeline_config=assistant_dists/dream/pipeline_conf.json'
```
**ВАЖНО:** Не храните токен бота в открытом репозитории!

# Конфигурация и использование proxy
Dream использует несколько конфигурационных файлов для docker-compose:
Expand Down
2 changes: 1 addition & 1 deletion assistant_dists/dream/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
agent:
command: sh -c 'bin/wait && python -m deeppavlov_agent.run -ch http_client -pl assistant_dists/dream/pipeline_conf.json --cors'
command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.pipeline_config=assistant_dists/dream/pipeline_conf.json'
environment:
WAIT_HOSTS: "convers-evaluator-annotator:8004,
spacy-nounphrases:8006, dff-program-y-skill:8008, sentseg:8011, convers-evaluation-selector:8009,
Expand Down
2 changes: 1 addition & 1 deletion assistant_dists/dream_mini/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
agent:
command: sh -c 'bin/wait && python -m deeppavlov_agent.run -ch http_client -pl assistant_dists/dream_mini/pipeline_conf.json --cors'
command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.pipeline_config=assistant_dists/dream_mini/pipeline_conf.json'
environment:
WAIT_HOSTS: "convers-evaluator-annotator:8004, dff-program-y-skill:8008, sentseg:8011, convers-evaluation-selector:8009,
dff-intent-responder-skill:8012, intent-catcher:8014, badlisted-words:8018,
Expand Down
2 changes: 1 addition & 1 deletion assistant_dists/dream_russian/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
agent:
command: sh -c 'bin/wait && python -m deeppavlov_agent.run -ch http_client -pl assistant_dists/dream_russian/pipeline_conf.json --cors'
command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.pipeline_config=assistant_dists/dream_russian/pipeline_conf.json'
environment:
WAIT_HOSTS: "dff-program-y-skill:8008, convers-evaluation-selector:8009,
dff-intent-responder-skill:8012, intent-catcher:8014, badlisted-words:8018,
Expand Down
2 changes: 1 addition & 1 deletion assistant_dists/dream_sfc/docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
agent:
command: sh -c 'bin/wait && python -m deeppavlov_agent.run -ch http_client -pl assistant_dists/dream_sfc/pipeline_conf.json --cors'
command: sh -c 'bin/wait && python -m deeppavlov_agent.run agent.pipeline_config=assistant_dists/dream_sfc/pipeline_conf.json'
environment:
WAIT_HOSTS: "convers-evaluator-annotator:8004,
spacy-nounphrases:8006, dff-program-y:8008, sentseg:8011, convers-evaluation-selector:8009, personality-catcher:8010,
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
agent:
env_file: [.env]
command: sh -c 'bin/wait && python -m deeppavlov_agent.run -ch http_client --cors'
command: sh -c 'bin/wait && python -m deeppavlov_agent.run'
build:
context: ./
dockerfile: dockerfile_agent
Expand Down
7 changes: 2 additions & 5 deletions dockerfile_agent
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,22 @@ RUN mkdir dp-agent
WORKDIR /dp-agent
# TODO: Copy only necessary dirs and files

# RUN pip install deeppavlov_agent==2.2.0 sentry-sdk==0.16.0 requests==2.24.0

RUN mkdir /pavlov && \
cd /pavlov && \
git clone https://github.com/deepmipt/DeepPavlov && \
cd DeepPavlov && \
pip install -e .

RUN pip install sentry-sdk==0.16.0 requests==2.24.0 pandas GitPython==3.1.14 pyaml openpyxl==3.0.0 xlrd==1.2.0
RUN pip install jinja2==3.0.3 Werkzeug==2.0.3
RUN pip install https://codeload.github.com/deepmipt/dp-agent/tar.gz/35960a8fb0ac8df8ecf75215c895a64c225c1490
RUN pip install pip install deeppavlov-agent==2.3.0a0

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONPATH "${PYTHONPATH}:/dp-agent"
ENV DPA_LAUNCHING_ENV "docker"

COPY . /dp-agent/.
COPY agent_settings.py /usr/local/lib/python3.7/site-packages/deeppavlov_agent/settings.py
#COPY agent_settings.py /usr/local/lib/python3.7/site-packages/deeppavlov_agent/settings.py
#RUN printf 'debug = False\nresponse_logger = False' > /dp-agent/dp_agent_settings.py


0 comments on commit 0304479

Please sign in to comment.