From 0fe58687f81acb644c7e8cb753f08730da5b742d Mon Sep 17 00:00:00 2001 From: dimitrievgs Date: Tue, 16 Sep 2025 01:36:47 +0300 Subject: [PATCH] fix to allow /api/messages// to get none node_id --- app/api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/api.py b/app/api.py index 9ec1963..19de844 100644 --- a/app/api.py +++ b/app/api.py @@ -68,6 +68,13 @@ def get_messages_from_root_to_node(graph_id, node_id): if not graph_data: return jsonify({"error": "Граф не найден."}, 404) + target_node_id = node_id + if node_id == 'last': + target_node_id = graph_data.get('current_node_id') + if not target_node_id: + return jsonify({"error": "В графе нет активного узла, до которого можно было бы получить сообщения."}, 404) + messages = graph_history_manager.get_messages_from_root_to_node( - graph_data, node_id) + graph_data, target_node_id) return jsonify(messages) +