From d40bc73cfc9b93655f051442dcd0213fe2f225bc Mon Sep 17 00:00:00 2001 From: a18875625 Date: Fri, 30 Oct 2026 20:11:32 +0300 Subject: [PATCH] Change reply topic in kafka main loop --- smart_kit/names/message_names.py | 3 +++ smart_kit/start_points/main_loop_kafka.py | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/smart_kit/names/message_names.py b/smart_kit/names/message_names.py index 79fd9f00..6adb3432 100644 --- a/smart_kit/names/message_names.py +++ b/smart_kit/names/message_names.py @@ -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" diff --git a/smart_kit/start_points/main_loop_kafka.py b/smart_kit/start_points/main_loop_kafka.py index cc5f6da6..d5854b5e 100644 --- a/smart_kit/start_points/main_loop_kafka.py +++ b/smart_kit/start_points/main_loop_kafka.py @@ -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 @@ -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( @@ -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)