Skip to content

Commit

Permalink
Merge pull request #554 from deeppavlov/dev
Browse files Browse the repository at this point in the history
Release v1.10.0
  • Loading branch information
dilyararimovna committed Aug 15, 2023
2 parents eed244e + 7846b28 commit b0f1df3
Show file tree
Hide file tree
Showing 94 changed files with 3,212 additions and 428 deletions.
3 changes: 2 additions & 1 deletion .env
Expand Up @@ -32,4 +32,5 @@ INFILLING_SERVICE_URL=http://infilling:8106/respond
DIALOGPT_CONTINUE_SERVICE_URL=http://dialogpt:8125/continue
PROMPT_STORYGPT_SERVICE_URL=http://prompt-storygpt:8127/respond
STORYGPT_SERVICE_URL=http://storygpt:8126/respond
FILE_SERVER_URL=http://files:3000
FILE_SERVER_URL=http://files:3000
SUMMARIZATION_SERVICE_URL=http://dialog-summarizer:8059/respond_batch
1 change: 1 addition & 0 deletions .env_ru
Expand Up @@ -21,3 +21,4 @@ BADLIST_ANNOTATOR_URL=http://badlisted-words-ru:8018/badlisted_words_batch
DP_WIKIDATA_URL=http://wiki-parser-ru:8077/model
DP_ENTITY_LINKING_URL=http://entity-linking-ru:8075/model
FILE_SERVER_URL=http://files:3000
SUMMARIZATION_SERVICE_URL=http://rut5-summarizer:8060/respond_batch
36 changes: 16 additions & 20 deletions MODELS.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions annotators/summarization_annotator/Dockerfile
@@ -0,0 +1,9 @@
FROM python:3.7.4

ARG SUMMARIZATION_REQUEST_TIMEOUT
ENV SUMMARIZATION_REQUEST_TIMEOUT ${SUMMARIZATION_REQUEST_TIMEOUT}

COPY ${WORK_DIR}/requirements.txt /src/requirements.txt
RUN pip install -r /src/requirements.txt
COPY ${WORK_DIR} /src
WORKDIR /src
7 changes: 7 additions & 0 deletions annotators/summarization_annotator/requirements.txt
@@ -0,0 +1,7 @@
sentry-sdk[flask]==0.14.1
flask==1.1.1
itsdangerous==2.0.1
gunicorn==19.9.0
requests==2.22.0
jinja2<=3.0.3
Werkzeug<=2.0.3
75 changes: 75 additions & 0 deletions annotators/summarization_annotator/server.py
@@ -0,0 +1,75 @@
import logging
import time
from os import getenv

import sentry_sdk
import requests
from flask import Flask, jsonify, request


sentry_sdk.init(getenv("SENTRY_DSN"))
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)
app = Flask(__name__)

SUMMARIZATION_REQUEST_TIMEOUT = int(getenv("SUMMARIZATION_REQUEST_TIMEOUT"))
SUMMARIZATION_SERVICE_URL = getenv("SUMMARIZATION_SERVICE_URL")
logger.info(f"summarization-annotator considered summarizer: {SUMMARIZATION_SERVICE_URL}")


def get_summary(dialog):
summary = ""
if len(dialog) != 11:
logger.debug(
f"summarization-annotator is not ready to summarize dialog as the length of unsummarized dialog is "
f"{len(dialog)} != 11"
)
return summary

logger.debug("summarization-annotator is ready to summarize dialog as the length of unsummarized dialog is 11")
dialog = dialog[:6]
for i in range(len(dialog)):
if i % 2 == 0:
dialog[i] = "User: " + dialog[i]
else:
dialog[i] = "Bot: " + dialog[i]
dialog = ["\n".join(dialog)]
logger.debug(f"summarization-annotator will summarize this: {dialog}")

try:
summary = requests.post(
SUMMARIZATION_SERVICE_URL,
json={"sentences": dialog},
timeout=SUMMARIZATION_REQUEST_TIMEOUT,
).json()[0]["batch"][0]
except Exception as exc:
logger.exception(exc)
sentry_sdk.capture_exception(exc)

return summary


@app.route("/respond", methods=["POST"])
def respond():
start_time = time.time()
dialogs_batch = request.json.get("dialogs", [])
summaries_batch = request.json.get("previous_summaries", [])
summarization_attribute = []

for dialog, prev_summary in zip(dialogs_batch, summaries_batch):
logger.debug(f"summarization-annotator received dialog: {dialog}")
logger.debug(f"summarization-annotator received previous summary: {[prev_summary]}")
result = prev_summary
new_summary = get_summary(dialog)
if new_summary:
result = f"{result} {new_summary}".strip()
summarization_attribute.append({"bot_attributes": {"summarized_dialog": result}})
logger.info(f"summarization-annotator output: {summarization_attribute}")

total_time = time.time() - start_time
logger.info(f"summarization-annotator exec time: {total_time:.2f}s")
return jsonify(summarization_attribute)


if __name__ == "__main__":
app.run(debug=False, host="0.0.0.0", port=8058)
@@ -0,0 +1,4 @@
SERVICE_PORT: 8058
SERVICE_NAME: summarization_annotator
SUMMARIZATION_REQUEST_TIMEOUT: 10
FLASK_APP: server
@@ -0,0 +1,26 @@
name: summarization-annotator
endpoints:
- respond
compose:
env_file:
- .env
build:
args:
SERVICE_PORT: 8058
SERVICE_NAME: summarization_annotator
SUMMARIZATION_REQUEST_TIMEOUT: 10
context: ./annotators/summarization_annotator/
command: flask run -h 0.0.0.0 -p 8058
environment:
- FLASK_APP=server
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 256M
volumes:
- ./annotators/summarization_annotator:/src
ports:
- 8058:8058
proxy: null
70 changes: 70 additions & 0 deletions annotators/summarization_annotator/test.py
@@ -0,0 +1,70 @@
import requests
from os import getenv


SUMMARIZATION_SERVICE_URL = getenv("SUMMARIZATION_SERVICE_URL")


def test_skill():
url = "http://0.0.0.0:8058/respond"

if SUMMARIZATION_SERVICE_URL == "http://dialog-summarizer:8059/respond_batch":
input_data = {
"dialogs": [
[
"Hi, my name is Mark!",
"Good morning, Mark! How can I assist you today?",
"Let's talk about cooking.",
"Sure! What is your favourite type of cuisine to cook or experiment with in the " "kitchen?",
"I like a wide range of cooking styles, such as Italian, Chinese, French and many " "more.",
"May I recommend you any Italian dish?",
"No. Better tell me what do you have in mind?",
"I've recently found a couple easy and healthy meals. How about cooking quinoa with "
"turkey and broccoli?",
"That sounds like a healthy and tasty meal! Quinoa is a great source of protein, and "
"when paired with lean turkey and broccoli, it's a well-rounded and balanced meal.",
"I am glad for you! I listened to my favorite music all day. "
"Such a great thing you know! Has anything extraordinary happened today?",
"I can tell you more about what made your day great or we can just chat?" "I'm happy to listen!",
]
],
"previous_summaries": [""],
}

desired_output = [
"Bot wants to know what is Mark's favorite type of cuisine to cook. Mark likes Italian, "
"Chinese, French and many other cooking styles."
]
else:
input_data = {
"dialogs": [
[
"Привет! У тебя есть хобби?",
"Мое хобби — кулинария.",
"Здорово! А ты любишь готовить?",
"Ага, я могу отлично приготовить разные блюда.",
"Ты собираешь кулинарные рецепты?",
"Да, уже есть большая коллекция.",
"А какая национальная кухня тебе нравится?",
"Конечно, русская.",
"Русские блюда очень оригинальные, вкусные и полезные.",
"А что ты любишь готовить больше всего?",
"Я люблю готовить мясные блюда. Так что приглашаю в гости!",
]
],
"previous_summaries": [""],
}

desired_output = [
"У тебя есть хобби — кулинария, а у тебя есть большая коллекция кулинарных рецептов. Bot: Я "
"собираю кулинарные рецепты, собираю кулинарные рецепты, собираю кулинарные рецепты."
]

result = requests.post(url, json=input_data).json()

assert result == [{"bot_attributes": {"summarized_dialog": desired_output[0]}}]
print("SUCCESS!")


if __name__ == "__main__":
test_skill()
3 changes: 3 additions & 0 deletions annotators/summarization_annotator/test.sh
@@ -0,0 +1,3 @@
#!/bin/bash

python test.py
10 changes: 10 additions & 0 deletions assistant_dists/dream/dev.yml
Expand Up @@ -141,6 +141,16 @@ services:
- "./common:/src/common"
ports:
- 8170:8170
summarization-annotator:
volumes:
- "./annotators/summarization_annotator:/src"
ports:
- 8058:8058
dialog-summarizer:
volumes:
- "./services/dialog_summarizer:/src"
ports:
- 8059:8059
openai-api-chatgpt-16k:
volumes:
- "./services/openai_api_lm:/src"
Expand Down
39 changes: 38 additions & 1 deletion assistant_dists/dream/docker-compose.override.yml
Expand Up @@ -8,7 +8,7 @@ services:
combined-classification:8087, fact-retrieval:8100, entity-detection:8103,
sentence-ranker:8128, property-extraction:8136, prompt-selector:8135, openai-api-chatgpt:8145,
dff-dream-persona-chatgpt-prompted-skill:8137, dff-dream-faq-prompted-skill:8170,
openai-api-chatgpt-16k:8167"
openai-api-chatgpt-16k:8167, summarization-annotator:8058, dialog-summarizer:8059"
WAIT_HOSTS_TIMEOUT: ${WAIT_TIMEOUT:-1000}
HIGH_PRIORITY_INTENTS: 1
RESTRICTION_FOR_SENSITIVE_CASE: 1
Expand Down Expand Up @@ -445,4 +445,41 @@ services:
reservations:
memory: 100M

summarization-annotator:
env_file: [ .env ]
build:
args:
SERVICE_PORT: 8058
SERVICE_NAME: summarization_annotator
SUMMARIZATION_REQUEST_TIMEOUT: 10
context: ./annotators/summarization_annotator/
command: flask run -h 0.0.0.0 -p 8058
environment:
- FLASK_APP=server
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 256M

dialog-summarizer:
env_file: [ .env ]
build:
args:
SERVICE_PORT: 8059
SERVICE_NAME: dialog_summarizer
PRETRAINED_MODEL_NAME: "knkarthick/MEETING_SUMMARY"
context: ./services/dialog_summarizer/
command: flask run -h 0.0.0.0 -p 8059
environment:
- CUDA_VISIBLE_DEVICES=0
- FLASK_APP=server
deploy:
resources:
limits:
memory: 4G
reservations:
memory: 4G

version: '3.7'
18 changes: 18 additions & 0 deletions assistant_dists/dream/pipeline_conf.json
Expand Up @@ -263,6 +263,24 @@
"component": "components/PbLNvh4hrvs47rPaf2bfYQ.yml",
"service": "annotators/combined_classification/service_configs/combined-classification"
}
},
"summarization_annotator": {
"connector": {
"protocol": "http",
"timeout": 10.0,
"url": "http://summarization-annotator:8058/respond"
},
"dialog_formatter": "state_formatters.dp_formatters:summarization_annotator_formatter",
"response_formatter": "state_formatters.dp_formatters:simple_formatter_service",
"previous_services": [
"annotators.spelling_preprocessing"
],
"state_manager_method": "update_attributes",
"is_enabled": true,
"source": {
"component": "components/riRfdGz86P51B9bL7fO6JR.yml",
"service": "annotators/summarization_annotator/service_configs/summarization-annotator"
}
}
},
"response_annotators": {
Expand Down
4 changes: 4 additions & 0 deletions assistant_dists/dream_alexa/docker-compose.override.yml
Expand Up @@ -24,6 +24,10 @@ services:
HIGH_PRIORITY_INTENTS: 1
RESTRICTION_FOR_SENSITIVE_CASE: 1
ALWAYS_TURN_ON_ALL_SKILLS: 0
ENABLE_NP_QUESTIONS: 1
ENABLE_SWITCH_TOPIC: 1
ENABLE_LINK_QUESTIONS: 1
ENABLE_NP_FACTS: 1
LANGUAGE: EN
FALLBACK_FILE: fallbacks_dream_en.json

Expand Down
3 changes: 2 additions & 1 deletion assistant_dists/dream_reasoning/docker-compose.override.yml
Expand Up @@ -118,9 +118,10 @@ services:
GENERATIVE_TIMEOUT: 120
N_UTTERANCES_CONTEXT: 1
ENVVARS_TO_SEND: OPENAI_API_KEY,GOOGLE_CSE_ID,GOOGLE_API_KEY,OPENWEATHERMAP_API_KEY,NEWS_API_KEY,WOLFRAMALPHA_APP_ID
TIME_SLEEP: 5
context: .
dockerfile: ./skills/dff_reasoning_skill/Dockerfile
command: gunicorn --workers=1 server:app -b 0.0.0.0:8169 --reload
command: gunicorn --workers=1 server:app -b 0.0.0.0:8169 --timeout 600
deploy:
resources:
limits:
Expand Down
10 changes: 10 additions & 0 deletions assistant_dists/dream_robot_prompted/cpu.yml
@@ -0,0 +1,10 @@
version: '3.7'
services:
combined-classification:
environment:
DEVICE: cpu
CUDA_VISIBLE_DEVICES: ""
sentence-ranker:
environment:
DEVICE: cpu
CUDA_VISIBLE_DEVICES: ""
6 changes: 6 additions & 0 deletions assistant_dists/dream_robot_prompted/db_conf.json
@@ -0,0 +1,6 @@
{
"host": "DB_HOST",
"port": "DB_PORT",
"name": "DB_NAME",
"env": true
}
50 changes: 50 additions & 0 deletions assistant_dists/dream_robot_prompted/dev.yml
@@ -0,0 +1,50 @@
# С такими volumes удобно дебажить, не нужно пересобирать контейнер каждый раз при изменении кода
services:
agent:
volumes:
- ".:/dp-agent"
ports:
- 4242:4242
sentseg:
volumes:
- "./annotators/SentSeg:/src"
ports:
- 8011:8011
ranking-based-response-selector:
volumes:
- "./response_selectors/ranking_based_response_selector:/src"
- "./common:/src/common"
ports:
- 8002:8002
combined-classification:
volumes:
- "./common:/src/common"
- "./annotators/combined_classification:/src"
ports:
- 8087:8087
sentence-ranker:
volumes:
- "./services/sentence_ranker:/src"
- "~/.deeppavlov/cache:/root/.cache"
ports:
- 8128:8128
prompt-selector:
volumes:
- "./annotators/prompt_selector:/src"
- "./common:/src/common"
ports:
- 8135:8135
openai-api-chatgpt:
volumes:
- "./services/openai_api_lm:/src"
- "./common:/src/common"
ports:
- 8145:8145
dff-robot-prompted-skill:
volumes:
- "./skills/dff_template_prompted_skill:/src"
- "./common:/src/common"
ports:
- 8179:8179

version: "3.7"

0 comments on commit b0f1df3

Please sign in to comment.