Merge branch 'main' into feat/rag-2

This commit is contained in:
twwu
2025-08-22 17:40:34 +08:00
113 changed files with 1945 additions and 269 deletions

View File

@ -7,7 +7,6 @@ from typing import TYPE_CHECKING, Any, Optional, Union
from uuid import uuid4
import sqlalchemy as sa
from flask_login import current_user
from sqlalchemy import DateTime, orm
from core.file.constants import maybe_file_object
@ -18,7 +17,6 @@ from core.workflow.constants import CONVERSATION_VARIABLE_NODE_ID, SYSTEM_VARIAB
from core.workflow.nodes.enums import NodeType
from factories.variable_factory import TypeMismatchError, build_segment_with_type
from libs.datetime_utils import naive_utc_now
from libs.helper import extract_tenant_id
from ._workflow_exc import NodeNotFoundError, WorkflowDataError
@ -363,8 +361,8 @@ class Workflow(Base):
if self._environment_variables is None:
self._environment_variables = "{}"
# Get tenant_id from current_user (Account or EndUser)
tenant_id = extract_tenant_id(current_user)
# Use workflow.tenant_id to avoid relying on request user in background threads
tenant_id = self.tenant_id
if not tenant_id:
return []
@ -394,8 +392,8 @@ class Workflow(Base):
self._environment_variables = "{}"
return
# Get tenant_id from current_user (Account or EndUser)
tenant_id = extract_tenant_id(current_user)
# Use workflow.tenant_id to avoid relying on request user in background threads
tenant_id = self.tenant_id
if not tenant_id:
self._environment_variables = "{}"