Merge pull request #90 from SuanmoSuanyangTechnology/feature/agent-tool_xjn
feat(workflow node)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import uuid
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from app.core.workflow.nodes.base_node import BaseNode, WorkflowState
|
from app.core.workflow.nodes.base_node import BaseNode, WorkflowState
|
||||||
@@ -24,10 +25,10 @@ class ToolNode(BaseNode):
|
|||||||
# 获取租户ID和用户ID
|
# 获取租户ID和用户ID
|
||||||
tenant_id = self.get_variable("sys.tenant_id", state)
|
tenant_id = self.get_variable("sys.tenant_id", state)
|
||||||
user_id = self.get_variable("sys.user_id", state)
|
user_id = self.get_variable("sys.user_id", state)
|
||||||
|
workspace_id = self.get_variable("sys.workspace_id", state)
|
||||||
|
|
||||||
# 如果没有租户ID,尝试从工作流ID获取
|
# 如果没有租户ID,尝试从工作流ID获取
|
||||||
if not tenant_id:
|
if not tenant_id:
|
||||||
workspace_id = self.get_variable("sys.workspace_id", state)
|
|
||||||
if workspace_id:
|
if workspace_id:
|
||||||
from app.repositories.tool_repository import ToolRepository
|
from app.repositories.tool_repository import ToolRepository
|
||||||
with get_db_read() as db:
|
with get_db_read() as db:
|
||||||
@@ -62,7 +63,8 @@ class ToolNode(BaseNode):
|
|||||||
tool_id=self.typed_config.tool_id,
|
tool_id=self.typed_config.tool_id,
|
||||||
parameters=rendered_parameters,
|
parameters=rendered_parameters,
|
||||||
tenant_id=tenant_id,
|
tenant_id=tenant_id,
|
||||||
user_id=user_id
|
user_id=uuid.UUID(user_id),
|
||||||
|
workspace_id=uuid.UUID(workspace_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.success:
|
if result.success:
|
||||||
|
|||||||
@@ -211,12 +211,11 @@ class ToolExecution(Base):
|
|||||||
token_usage = Column(JSON)
|
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)
|
workspace_id = Column(UUID(as_uuid=True), ForeignKey("workspaces.id"), nullable=False, index=True)
|
||||||
|
|
||||||
# 关联关系
|
# 关联关系
|
||||||
tool_config = relationship("ToolConfig", back_populates="executions")
|
tool_config = relationship("ToolConfig", back_populates="executions")
|
||||||
user = relationship("User")
|
|
||||||
workspace = relationship("Workspace")
|
workspace = relationship("Workspace")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user