mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 02:43:49 +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 json
|
||||||
import logging
|
import logging
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ graphon NodeEventBase events consumable by the workflow engine.
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Generator
|
from collections.abc import Generator
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from graphon.model_runtime.entities import LLMResultChunk
|
from graphon.model_runtime.entities import LLMResultChunk
|
||||||
from graphon.node_events import (
|
from graphon.node_events import (
|
||||||
|
|||||||
@ -10,12 +10,11 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from collections.abc import Generator, Mapping, Sequence
|
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.enums import WorkflowNodeExecutionMetadataKey, WorkflowNodeExecutionStatus
|
||||||
from graphon.model_runtime.entities import (
|
from graphon.model_runtime.entities import (
|
||||||
AssistantPromptMessage,
|
AssistantPromptMessage,
|
||||||
LLMResult,
|
|
||||||
LLMResultChunk,
|
LLMResultChunk,
|
||||||
PromptMessage,
|
PromptMessage,
|
||||||
SystemPromptMessage,
|
SystemPromptMessage,
|
||||||
@ -23,15 +22,10 @@ from graphon.model_runtime.entities import (
|
|||||||
UserPromptMessage,
|
UserPromptMessage,
|
||||||
)
|
)
|
||||||
from graphon.model_runtime.entities.llm_entities import LLMUsage
|
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.model_runtime.entities.model_entities import ModelFeature, ModelType
|
||||||
from graphon.node_events import (
|
from graphon.node_events import (
|
||||||
NodeEventBase,
|
NodeEventBase,
|
||||||
NodeRunResult,
|
NodeRunResult,
|
||||||
StreamChunkEvent,
|
|
||||||
StreamCompletedEvent,
|
StreamCompletedEvent,
|
||||||
)
|
)
|
||||||
from graphon.nodes.base.node import Node
|
from graphon.nodes.base.node import Node
|
||||||
@ -545,11 +539,11 @@ class AgentV2Node(Node[AgentV2NodeData]):
|
|||||||
content = jinja2_text or text
|
content = jinja2_text or text
|
||||||
selectors = VariableTemplateParser(content).extract_variable_selectors()
|
selectors = VariableTemplateParser(content).extract_variable_selectors()
|
||||||
for selector in selectors:
|
for selector in selectors:
|
||||||
result[selector.variable] = selector.value_selector
|
result[selector.variable] = list(selector.value_selector)
|
||||||
else:
|
else:
|
||||||
text_content = getattr(node_data.prompt_template, "text", "") or ""
|
text_content = getattr(node_data.prompt_template, "text", "") or ""
|
||||||
selectors = VariableTemplateParser(text_content).extract_variable_selectors()
|
selectors = VariableTemplateParser(text_content).extract_variable_selectors()
|
||||||
for selector in 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()}
|
return {f"{node_id}.{key}": value for key, value in result.items()}
|
||||||
|
|||||||
@ -8,12 +8,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from collections.abc import Generator
|
|
||||||
from typing import TYPE_CHECKING, Any
|
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.entities import AgentToolEntity, ExecutionContext
|
||||||
from core.agent.patterns.base import ToolInvokeHook
|
from core.agent.patterns.base import ToolInvokeHook
|
||||||
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler
|
from core.callback_handler.workflow_tool_callback_handler import DifyWorkflowCallbackHandler
|
||||||
|
|||||||
@ -136,8 +136,8 @@ class TestAgentChatAppRunnerRun:
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("mode", "expected_runner"),
|
("mode", "expected_runner"),
|
||||||
[
|
[
|
||||||
(LLMMode.CHAT, "CotChatAgentRunner"),
|
(LLMMode.CHAT, "AgentAppRunner"),
|
||||||
(LLMMode.COMPLETION, "CotCompletionAgentRunner"),
|
(LLMMode.COMPLETION, "AgentAppRunner"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_run_chain_of_thought_modes(self, runner, mocker, mode, expected_runner):
|
def test_run_chain_of_thought_modes(self, runner, mocker, mode, expected_runner):
|
||||||
@ -286,7 +286,7 @@ class TestAgentChatAppRunnerRun:
|
|||||||
)
|
)
|
||||||
|
|
||||||
runner_cls = mocker.MagicMock()
|
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_instance = mocker.MagicMock()
|
||||||
runner_cls.return_value = runner_instance
|
runner_cls.return_value = runner_instance
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user