mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
fix: resolve CI failures — unused imports, type errors, test updates
- Remove 12 unused imports across node.py, tool_manager.py, event_adapter.py, legacy_response_adapter.py - Fix Sequence[str] → list[str] type annotation in node.py - Update test_agent_chat_app_runner.py: CotChatAgentRunner → AgentAppRunner (old runner classes replaced by unified runner) Made-with: Cursor
This commit is contained in:
parent
c03b25a940
commit
5f87239abc
@ -12,7 +12,6 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
from collections.abc import Generator
|
||||
from typing import Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ graphon NodeEventBase events consumable by the workflow engine.
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Generator
|
||||
from typing import Any
|
||||
|
||||
from graphon.model_runtime.entities import LLMResultChunk
|
||||
from graphon.node_events import (
|
||||
|
||||
@ -10,12 +10,11 @@ from __future__ import annotations
|
||||
import logging
|
||||
import re
|
||||
from collections.abc import Generator, Mapping, Sequence
|
||||
from typing import TYPE_CHECKING, Any, Literal, cast
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
|
||||
from graphon.enums import WorkflowNodeExecutionMetadataKey, WorkflowNodeExecutionStatus
|
||||
from graphon.model_runtime.entities import (
|
||||
AssistantPromptMessage,
|
||||
LLMResult,
|
||||
LLMResultChunk,
|
||||
PromptMessage,
|
||||
SystemPromptMessage,
|
||||
@ -23,15 +22,10 @@ from graphon.model_runtime.entities import (
|
||||
UserPromptMessage,
|
||||
)
|
||||
from graphon.model_runtime.entities.llm_entities import LLMUsage
|
||||
from graphon.model_runtime.entities.message_entities import (
|
||||
ImagePromptMessageContent,
|
||||
PromptMessageContentUnionTypes,
|
||||
)
|
||||
from graphon.model_runtime.entities.model_entities import ModelFeature, ModelType
|
||||
from graphon.node_events import (
|
||||
NodeEventBase,
|
||||
NodeRunResult,
|
||||
StreamChunkEvent,
|
||||
StreamCompletedEvent,
|
||||
)
|
||||
from graphon.nodes.base.node import Node
|
||||
@ -545,11 +539,11 @@ class AgentV2Node(Node[AgentV2NodeData]):
|
||||
content = jinja2_text or text
|
||||
selectors = VariableTemplateParser(content).extract_variable_selectors()
|
||||
for selector in selectors:
|
||||
result[selector.variable] = selector.value_selector
|
||||
result[selector.variable] = list(selector.value_selector)
|
||||
else:
|
||||
text_content = getattr(node_data.prompt_template, "text", "") or ""
|
||||
selectors = VariableTemplateParser(text_content).extract_variable_selectors()
|
||||
for selector in selectors:
|
||||
result[selector.variable] = selector.value_selector
|
||||
result[selector.variable] = list(selector.value_selector)
|
||||
|
||||
return {f"{node_id}.{key}": value for key, value in result.items()}
|
||||
|
||||
@ -8,12 +8,8 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from collections.abc import Generator
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from graphon.file import File
|
||||
from graphon.model_runtime.entities import PromptMessageTool
|
||||
|
||||
from core.agent.entities import AgentToolEntity, ExecutionContext
|
||||
from core.agent.patterns.base import ToolInvokeHook
|
||||
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler
|
||||
|
||||
@ -136,8 +136,8 @@ class TestAgentChatAppRunnerRun:
|
||||
@pytest.mark.parametrize(
|
||||
("mode", "expected_runner"),
|
||||
[
|
||||
(LLMMode.CHAT, "CotChatAgentRunner"),
|
||||
(LLMMode.COMPLETION, "CotCompletionAgentRunner"),
|
||||
(LLMMode.CHAT, "AgentAppRunner"),
|
||||
(LLMMode.COMPLETION, "AgentAppRunner"),
|
||||
],
|
||||
)
|
||||
def test_run_chain_of_thought_modes(self, runner, mocker, mode, expected_runner):
|
||||
@ -286,7 +286,7 @@ class TestAgentChatAppRunnerRun:
|
||||
)
|
||||
|
||||
runner_cls = mocker.MagicMock()
|
||||
mocker.patch("core.app.apps.agent_chat.app_runner.FunctionCallAgentRunner", runner_cls)
|
||||
mocker.patch("core.app.apps.agent_chat.app_runner.AgentAppRunner", runner_cls)
|
||||
|
||||
runner_instance = mocker.MagicMock()
|
||||
runner_cls.return_value = runner_instance
|
||||
|
||||
Loading…
Reference in New Issue
Block a user