feat(workflow node): The execution records of the tool remove the foreign key that binds to the user, and directly store the user ID.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import re
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
from app.core.workflow.nodes.base_node import BaseNode, WorkflowState
|
||||
@@ -24,10 +25,10 @@ class ToolNode(BaseNode):
|
||||
# 获取租户ID和用户ID
|
||||
tenant_id = self.get_variable("sys.tenant_id", state)
|
||||
user_id = self.get_variable("sys.user_id", state)
|
||||
workspace_id = self.get_variable("sys.workspace_id", state)
|
||||
|
||||
# 如果没有租户ID,尝试从工作流ID获取
|
||||
if not tenant_id:
|
||||
workspace_id = self.get_variable("sys.workspace_id", state)
|
||||
if workspace_id:
|
||||
from app.repositories.tool_repository import ToolRepository
|
||||
with get_db_read() as db:
|
||||
@@ -62,7 +63,8 @@ class ToolNode(BaseNode):
|
||||
tool_id=self.typed_config.tool_id,
|
||||
parameters=rendered_parameters,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id
|
||||
user_id=uuid.UUID(user_id),
|
||||
workspace_id=uuid.UUID(workspace_id)
|
||||
)
|
||||
|
||||
if result.success:
|
||||
|
||||
@@ -211,12 +211,11 @@ class ToolExecution(Base):
|
||||
token_usage = Column(JSON)
|
||||
|
||||
# 用户信息
|
||||
user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), index=True)
|
||||
user_id = Column(UUID(as_uuid=True), index=True, nullable=True)
|
||||
workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id"), nullable=False, index=True)
|
||||
|
||||
# 关联关系
|
||||
tool_config = relationship("ToolConfig", back_populates="executions")
|
||||
user = relationship("User")
|
||||
workspace = relationship("Workspace")
|
||||
|
||||
def __repr__(self):
|
||||
|
||||
Reference in New Issue
Block a user