Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions smart_kit/names/message_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
RUN_APP = "RUN_APP"
CLOSE_APP = "CLOSE_APP"
SERVER_ACTION = "SERVER_ACTION"
POLICY_RUN_APP = "POLICY_RUN_APP"
INTENT_RUN_APP = "INTENT_RUN_APP"
DATA_FOR_GIGACHAT = "DATA_FOR_GIGACHAT"
GET_PROFILE_DATA = "GET_PROFILE_DATA"
TAKE_PROFILE_DATA = "TAKE_PROFILE_DATA"
TAKE_RUNTIME_PERMISSIONS = "TAKE_RUNTIME_PERMISSIONS"
21 changes: 16 additions & 5 deletions smart_kit/start_points/main_loop_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
from smart_kit.message.get_to_message import get_to_message
from smart_kit.message.smartapp_to_message import SmartAppToMessage
from smart_kit.names import message_names
from smart_kit.names.message_names import ANSWER_TO_USER, RUN_APP, MESSAGE_TO_SKILL, SERVER_ACTION, CLOSE_APP
from smart_kit.names.message_names import (ANSWER_TO_USER, ERROR, RUN_APP, MESSAGE_TO_SKILL, SERVER_ACTION,
CLOSE_APP, NOTHING_FOUND, INTENT_RUN_APP, POLICY_RUN_APP,
DATA_FOR_GIGACHAT, LOCAL_TIMEOUT)
from smart_kit.request.kafka_request import SmartKitKafkaRequest
from smart_kit.start_points.base_main_loop import BaseMainLoop
from smart_kit.start_points.constants import WORKER_EXCEPTION, POD_UP
Expand Down Expand Up @@ -340,10 +342,19 @@ def _generate_answers(self, user: User, commands, message, **kwargs):
commands = commands or []

commands = combine_commands(commands, user)

app_answers = {
ANSWER_TO_USER,
ERROR,
NOTHING_FOUND,
LOCAL_TIMEOUT,
CLOSE_APP,
INTENT_RUN_APP,
POLICY_RUN_APP,
DATA_FOR_GIGACHAT
}
for command in commands:
if (command.name in ["ANSWER_TO_USER", "ERROR", "NOTHING_FOUND"] or
(command.name == "DATA_FOR_GIGACHAT" and command.payload.get("function_result"))):
if (command.name in [ANSWER_TO_USER, ERROR, NOTHING_FOUND] or
(command.name == DATA_FOR_GIGACHAT and command.payload.get("function_result"))):
if not user.settings["template_settings"].get("stats_off"):
finish_ts = time.time()
command.payload["stats"] = Stats(
Expand All @@ -361,7 +372,7 @@ def _generate_answers(self, user: User, commands, message, **kwargs):
request.update_empty_items({
"kafka_key": kafka_key,
"topic_key": topic_key,
"topic": user.local_vars.get(KAFKA_REPLY_TOPIC) if command.name == ANSWER_TO_USER else None
"topic": user.local_vars.get(KAFKA_REPLY_TOPIC) if command.name in app_answers else None
})

to_message = get_to_message(command.name)
Expand Down
Loading