style(workflow): enforce PEP8 style and remove redundant imports

This commit is contained in:
Eternity
2026-01-27 17:51:27 +08:00
parent 166d05afe9
commit 2a10e9f7ee
11 changed files with 25 additions and 28 deletions

View File

@@ -7,7 +7,6 @@ from textwrap import dedent
from typing import Any from typing import Any
import httpx import httpx
from sympy.physics.vector import vlatex
from app.core.workflow.nodes import BaseNode, WorkflowState from app.core.workflow.nodes import BaseNode, WorkflowState
from app.core.workflow.nodes.base_config import VariableType from app.core.workflow.nodes.base_config import VariableType

View File

@@ -1,5 +1,4 @@
import asyncio import asyncio
import copy
import logging import logging
import re import re
from typing import Any from typing import Any

View File

@@ -6,7 +6,6 @@ from langgraph.graph.state import CompiledStateGraph
from app.core.workflow.nodes import WorkflowState from app.core.workflow.nodes import WorkflowState
from app.core.workflow.nodes.base_node import BaseNode from app.core.workflow.nodes.base_node import BaseNode
from app.core.workflow.nodes.cycle_graph.config import LoopNodeConfig, IterationNodeConfig
from app.core.workflow.nodes.cycle_graph.iteration import IterationRuntime from app.core.workflow.nodes.cycle_graph.iteration import IterationRuntime
from app.core.workflow.nodes.cycle_graph.loop import LoopRuntime from app.core.workflow.nodes.cycle_graph.loop import LoopRuntime
from app.core.workflow.nodes.enums import NodeType from app.core.workflow.nodes.enums import NodeType

View File

@@ -13,7 +13,7 @@ logger = logging.getLogger(__name__)
class IfElseNode(BaseNode): class IfElseNode(BaseNode):
def __init__(self, node_config: dict[str, Any], workflow_config: dict[str, Any]): def __init__(self, node_config: dict[str, Any], workflow_config: dict[str, Any]):
super().__init__(node_config, workflow_config) super().__init__(node_config, workflow_config)
self.typed_config: IfElseNodeConfig | None= None self.typed_config: IfElseNodeConfig | None = None
@staticmethod @staticmethod
def _evaluate(operator, instance: CompareOperatorInstance) -> Any: def _evaluate(operator, instance: CompareOperatorInstance) -> Any:

View File

@@ -1,8 +1,6 @@
import uuid
from uuid import UUID from uuid import UUID
from pydantic import Field from pydantic import Field
from typing import Literal
from app.core.workflow.nodes.base_config import BaseNodeConfig from app.core.workflow.nodes.base_config import BaseNodeConfig

View File

@@ -24,7 +24,7 @@ class MemoryReadNode(BaseNode):
return await MemoryAgentService().read_memory( return await MemoryAgentService().read_memory(
end_user_id=end_user_id, end_user_id=end_user_id,
message=self._render_template(self.typed_config.message, state), message=self._render_template(self.typed_config.message, state),
config_id=str(self.typed_config.config_id), config_id=self.typed_config.config_id,
search_switch=self.typed_config.search_switch, search_switch=self.typed_config.search_switch,
history=[], history=[],
db=db, db=db,

View File

@@ -5,6 +5,7 @@ from pydantic import Field, BaseModel
from app.core.workflow.nodes.base_config import BaseNodeConfig from app.core.workflow.nodes.base_config import BaseNodeConfig
class ClassifierConfig(BaseModel): class ClassifierConfig(BaseModel):
"""分类器节点配置""" """分类器节点配置"""

View File

@@ -78,7 +78,8 @@ class QuestionClassifierNode(BaseNode):
if not question: if not question:
logger.warning( logger.warning(
f"节点 {self.node_id} 未获取到输入问题,使用默认分支" f"节点 {self.node_id} 未获取到输入问题,使用默认分支"
f"默认分支{DEFAULT_EMPTY_QUESTION_CASE},分类总数:{category_count}" f"(默认分支:{DEFAULT_EMPTY_QUESTION_CASE}"
f"分类总数: {category_count})"
) )
# 若分类列表为空返回默认unknown分支否则返回CASE1 # 若分类列表为空返回默认unknown分支否则返回CASE1
if category_count > 0: if category_count > 0:

View File

@@ -79,7 +79,7 @@ class ToolNode(BaseNode):
else: else:
logger.error(f"节点 {self.node_id} 工具执行失败: {result.error}") logger.error(f"节点 {self.node_id} 工具执行失败: {result.error}")
return { return {
"data": result.error if isinstance(result.error, str) else json.dumps(result.error, ensure_ascii=False), "data": result.error if isinstance(result.error, str) else json.dumps(result.error, ensure_ascii=False),
"error_code": result.error_code, "error_code": result.error_code,
"execution_time": result.execution_time "execution_time": result.execution_time
} }