Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

chore: Update the value of sys.dialogue_count to start from 1. (#25905)

Novice8f86f5749d9a
diff --git a/api/core/app/apps/advanced_chat/app_generator.py b/api/core/app/apps/advanced_chat/app_generator.py
index 35fdb865edb..b6234491c53 100644
--- a/api/core/app/apps/advanced_chat/app_generator.py
+++ b/api/core/app/apps/advanced_chat/app_generator.py
@@ -420,7 +420,9 @@ class AdvancedChatAppGenerator(MessageBasedAppGenerator):
db.session.refresh(conversation)
# get conversation dialogue count
- self._dialogue_count = get_thread_messages_length(conversation.id)
+ # NOTE: dialogue_count should not start from 0,
+ # because during the first conversation, dialogue_count should be 1.
+ self._dialogue_count = get_thread_messages_length(conversation.id) + 1
# init queue manager
queue_manager = MessageBasedAppQueueManager(
diff --git a/api/services/workflow_service.py b/api/services/workflow_service.py
index 2eb54dade30..97168c462b6 100644
--- a/api/services/workflow_service.py
+++ b/api/services/workflow_service.py
@@ -1008,7 +1008,7 @@ def _setup_variable_pool(
if workflow.type != WorkflowType.WORKFLOW.value:
system_variable.query = query
system_variable.conversation_id = conversation_id
- system_variable.dialogue_count = 0
+ system_variable.dialogue_count = 1
else:
system_variable = SystemVariable.empty()