Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
chore: removing unused imports in tests (#9049)
Bowen Liang7c0b159a81f0
diff --git a/api/app.py b/api/app.pyindex 1b58beee158..0662d94e1b4 100644--- a/api/app.py+++ b/api/app.py@@ -26,7 +26,7 @@ from commands import register_commandsfrom configs import dify_config# DO NOT REMOVE BELOW-from events import event_handlers+from events import event_handlers # noqa: F401from extensions import (ext_celery,ext_code_based_extension,@@ -45,7 +45,7 @@ from extensions.ext_login import login_managerfrom libs.passport import PassportService# TODO: Find a way to avoid importing models here-from models import account, dataset, model, source, task, tool, tools, web+from models import account, dataset, model, source, task, tool, tools, web # noqa: F401from services.account_service import AccountService# DO NOT REMOVE ABOVE@@ -181,10 +181,10 @@ def load_user_from_request(request_from_flask_login):decoded = PassportService().verify(auth_token)user_id = decoded.get("user_id")- account = AccountService.load_logged_in_account(account_id=user_id, token=auth_token)- if account:- contexts.tenant_id.set(account.current_tenant_id)- return account+ logged_in_account = AccountService.load_logged_in_account(account_id=user_id, token=auth_token)+ if logged_in_account:+ contexts.tenant_id.set(logged_in_account.current_tenant_id)+ return logged_in_account@login_manager.unauthorized_handlerdiff --git a/api/poetry.lock b/api/poetry.lockindex c24ec81639b..4b9fdd15263 100644--- a/api/poetry.lock+++ b/api/poetry.lock@@ -10595,4 +10595,4 @@ cffi = ["cffi (>=1.11)"][metadata]lock-version = "2.0"python-versions = ">=3.10,<3.13"-content-hash = "dbcbcd7addb7c35c67f074fce00f6e25ec1e225498e5b9de3ef2fcd6af749bf6"+content-hash = "d29d0c4ce384ef94fe65f0a2a145898bd1a117d4fd59c217d15bbb8993f4ce4e"diff --git a/api/pyproject.toml b/api/pyproject.tomlindex 0266edc4d3f..1c12cc3a369 100644--- a/api/pyproject.toml+++ b/api/pyproject.toml@@ -74,8 +74,6 @@ ignore = [[tool.ruff.lint.per-file-ignores]"app.py" = [- "F401", # unused-import- "F811", # redefined-while-unused]"__init__.py" = ["F401", # unused-import@@ -88,10 +86,15 @@ ignore = ["N803", # invalid-argument-name]"tests/*" = [- "F401", # unused-import"F811", # redefined-while-unused]+[tool.ruff.lint.pyflakes]+allowed-unused-imports=[+ "_pytest.monkeypatch",+ "tests.integration_tests",+]+[tool.ruff.format]exclude = []@@ -260,4 +263,4 @@ optional = true[tool.poetry.group.lint.dependencies]dotenv-linter = "~0.5.0"-ruff = "~0.6.8"+ruff = "~0.6.9"diff --git a/api/tests/integration_tests/model_runtime/__mock/anthropic.py b/api/tests/integration_tests/model_runtime/__mock/anthropic.pyindex 79a3dc03941..5092af4f13b 100644--- a/api/tests/integration_tests/model_runtime/__mock/anthropic.py+++ b/api/tests/integration_tests/model_runtime/__mock/anthropic.py@@ -5,7 +5,7 @@ from typing import Any, Literal, Unionimport anthropicimport pytestfrom _pytest.monkeypatch import MonkeyPatch-from anthropic import Anthropic, Stream+from anthropic import Streamfrom anthropic.resources import Messagesfrom anthropic.types import (ContentBlock,diff --git a/api/tests/integration_tests/model_runtime/__mock/nomic_embeddings.py b/api/tests/integration_tests/model_runtime/__mock/nomic_embeddings.pyindex 281e866e45c..6a25398cbf0 100644--- a/api/tests/integration_tests/model_runtime/__mock/nomic_embeddings.py+++ b/api/tests/integration_tests/model_runtime/__mock/nomic_embeddings.py@@ -1,6 +1,6 @@import osfrom collections.abc import Callable-from typing import Any, Literal, Union+from typing import Any, Literalimport pytestdiff --git a/api/tests/integration_tests/model_runtime/__mock/openai_chat.py b/api/tests/integration_tests/model_runtime/__mock/openai_chat.pyindex 439f7d56e9b..1dc5df76674 100644--- a/api/tests/integration_tests/model_runtime/__mock/openai_chat.py+++ b/api/tests/integration_tests/model_runtime/__mock/openai_chat.py@@ -1,6 +1,6 @@import refrom collections.abc import Generator-from json import dumps, loads+from json import dumpsfrom time import time# import monkeypatch@@ -11,11 +11,9 @@ from openai._types import NOT_GIVEN, NotGivenfrom openai.resources.chat.completions import Completionsfrom openai.types import Completion as CompletionMessagefrom openai.types.chat import (- ChatCompletion,ChatCompletionChunk,ChatCompletionMessageParam,ChatCompletionMessageToolCall,- ChatCompletionToolChoiceOptionParam,ChatCompletionToolParam,completion_create_params,)diff --git a/api/tests/integration_tests/model_runtime/__mock/openai_embeddings.py b/api/tests/integration_tests/model_runtime/__mock/openai_embeddings.pyindex e27b9891f5c..3cc1fa9ff1d 100644--- a/api/tests/integration_tests/model_runtime/__mock/openai_embeddings.py+++ b/api/tests/integration_tests/model_runtime/__mock/openai_embeddings.py@@ -1,7 +1,6 @@import refrom typing import Any, Literal, Union-from openai import OpenAIfrom openai._types import NOT_GIVEN, NotGivenfrom openai.resources.embeddings import Embeddingsfrom openai.types.create_embedding_response import CreateEmbeddingResponse, Usagediff --git a/api/tests/integration_tests/model_runtime/__mock/openai_remote.py b/api/tests/integration_tests/model_runtime/__mock/openai_remote.pyindex cb8f2495438..704dbad5d28 100644--- a/api/tests/integration_tests/model_runtime/__mock/openai_remote.py+++ b/api/tests/integration_tests/model_runtime/__mock/openai_remote.py@@ -1,6 +1,5 @@from time import time-from openai.resources.models import Modelsfrom openai.types.model import Modeldiff --git a/api/tests/integration_tests/model_runtime/__mock/xinference.py b/api/tests/integration_tests/model_runtime/__mock/xinference.pyindex 8deb50635f3..5f7dad50c10 100644--- a/api/tests/integration_tests/model_runtime/__mock/xinference.py+++ b/api/tests/integration_tests/model_runtime/__mock/xinference.py@@ -5,7 +5,6 @@ from typing import Unionimport pytestfrom _pytest.monkeypatch import MonkeyPatchfrom requests import Response-from requests.exceptions import ConnectionErrorfrom requests.sessions import Sessionfrom xinference_client.client.restful.restful_client import (Client,diff --git a/api/tests/integration_tests/model_runtime/azure_ai_studio/test_llm.py b/api/tests/integration_tests/model_runtime/azure_ai_studio/test_llm.pyindex 8655b43d8f0..85a4f7734dc 100644--- a/api/tests/integration_tests/model_runtime/azure_ai_studio/test_llm.py+++ b/api/tests/integration_tests/model_runtime/azure_ai_studio/test_llm.py@@ -6,10 +6,7 @@ import pytestfrom core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDeltafrom core.model_runtime.entities.message_entities import (AssistantPromptMessage,- ImagePromptMessageContent,- PromptMessageTool,SystemPromptMessage,- TextPromptMessageContent,UserPromptMessage,)from core.model_runtime.errors.validate import CredentialsValidateFailedErrordiff --git a/api/tests/integration_tests/model_runtime/chatglm/test_llm.py b/api/tests/integration_tests/model_runtime/chatglm/test_llm.pyindex 418e88874d1..a7c5229e051 100644--- a/api/tests/integration_tests/model_runtime/chatglm/test_llm.py+++ b/api/tests/integration_tests/model_runtime/chatglm/test_llm.py@@ -8,7 +8,6 @@ from core.model_runtime.entities.message_entities import (AssistantPromptMessage,PromptMessageTool,SystemPromptMessage,- TextPromptMessageContent,UserPromptMessage,)from core.model_runtime.entities.model_entities import AIModelEntitydiff --git a/api/tests/integration_tests/model_runtime/huggingface_tei/test_rerank.py b/api/tests/integration_tests/model_runtime/huggingface_tei/test_rerank.pyindex 45370d9fba4..cd1c20dd026 100644--- a/api/tests/integration_tests/model_runtime/huggingface_tei/test_rerank.py+++ b/api/tests/integration_tests/model_runtime/huggingface_tei/test_rerank.py@@ -2,8 +2,7 @@ import osimport pytest-from core.model_runtime.entities.rerank_entities import RerankDocument, RerankResult-from core.model_runtime.entities.text_embedding_entities import TextEmbeddingResult+from core.model_runtime.entities.rerank_entities import RerankResultfrom core.model_runtime.errors.validate import CredentialsValidateFailedErrorfrom core.model_runtime.model_providers.huggingface_tei.rerank.rerank import (HuggingfaceTeiRerankModel,diff --git a/api/tests/integration_tests/model_runtime/localai/test_llm.py b/api/tests/integration_tests/model_runtime/localai/test_llm.pyindex aa5436c34fc..51e899fd518 100644--- a/api/tests/integration_tests/model_runtime/localai/test_llm.py+++ b/api/tests/integration_tests/model_runtime/localai/test_llm.py@@ -8,10 +8,8 @@ from core.model_runtime.entities.message_entities import (AssistantPromptMessage,PromptMessageTool,SystemPromptMessage,- TextPromptMessageContent,UserPromptMessage,)-from core.model_runtime.entities.model_entities import ParameterRulefrom core.model_runtime.errors.validate import CredentialsValidateFailedErrorfrom core.model_runtime.model_providers.localai.llm.llm import LocalAILanguageModeldiff --git a/api/tests/integration_tests/model_runtime/nomic/test_provider.py b/api/tests/integration_tests/model_runtime/nomic/test_provider.pyindex 6cad400c069..ece4bb92008 100644--- a/api/tests/integration_tests/model_runtime/nomic/test_provider.py+++ b/api/tests/integration_tests/model_runtime/nomic/test_provider.py@@ -4,7 +4,6 @@ import pytestfrom core.model_runtime.errors.validate import CredentialsValidateFailedErrorfrom core.model_runtime.model_providers.nomic.nomic import NomicAtlasProvider-from core.model_runtime.model_providers.nomic.text_embedding.text_embedding import NomicTextEmbeddingModelfrom tests.integration_tests.model_runtime.__mock.nomic_embeddings import setup_nomic_mockdiff --git a/api/tests/integration_tests/model_runtime/novita/test_llm.py b/api/tests/integration_tests/model_runtime/novita/test_llm.pyindex 35fa0dc1904..9f92679cd5c 100644--- a/api/tests/integration_tests/model_runtime/novita/test_llm.py+++ b/api/tests/integration_tests/model_runtime/novita/test_llm.py@@ -6,7 +6,6 @@ import pytestfrom core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDeltafrom core.model_runtime.entities.message_entities import (AssistantPromptMessage,- PromptMessageTool,SystemPromptMessage,UserPromptMessage,)diff --git a/api/tests/integration_tests/model_runtime/oci/test_llm.py b/api/tests/integration_tests/model_runtime/oci/test_llm.pyindex 531f26a32e6..bd5d27eb0f2 100644--- a/api/tests/integration_tests/model_runtime/oci/test_llm.py+++ b/api/tests/integration_tests/model_runtime/oci/test_llm.py@@ -8,7 +8,6 @@ from core.model_runtime.entities.message_entities import (AssistantPromptMessage,PromptMessageTool,SystemPromptMessage,- TextPromptMessageContent,UserPromptMessage,)from core.model_runtime.errors.validate import CredentialsValidateFailedErrordiff --git a/api/tests/integration_tests/model_runtime/openai/test_llm.py b/api/tests/integration_tests/model_runtime/openai/test_llm.pyindex 3b3ea9ec800..41c99f68756 100644--- a/api/tests/integration_tests/model_runtime/openai/test_llm.py+++ b/api/tests/integration_tests/model_runtime/openai/test_llm.py@@ -14,7 +14,6 @@ from core.model_runtime.entities.message_entities import ()from core.model_runtime.entities.model_entities import AIModelEntity, ModelTypefrom core.model_runtime.errors.validate import CredentialsValidateFailedError-from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModelfrom core.model_runtime.model_providers.openai.llm.llm import OpenAILargeLanguageModel"""FOR MOCK FIXTURES, DO NOT REMOVE"""diff --git a/api/tests/integration_tests/model_runtime/openrouter/test_llm.py b/api/tests/integration_tests/model_runtime/openrouter/test_llm.pyindex ce4876a73a7..1b0cc6bf4b8 100644--- a/api/tests/integration_tests/model_runtime/openrouter/test_llm.py+++ b/api/tests/integration_tests/model_runtime/openrouter/test_llm.py@@ -6,7 +6,6 @@ import pytestfrom core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDeltafrom core.model_runtime.entities.message_entities import (AssistantPromptMessage,- PromptMessageTool,SystemPromptMessage,UserPromptMessage,)diff --git a/api/tests/integration_tests/model_runtime/sagemaker/test_provider.py b/api/tests/integration_tests/model_runtime/sagemaker/test_provider.pyindex 9f0b439d6c3..41de2a17fda 100644--- a/api/tests/integration_tests/model_runtime/sagemaker/test_provider.py+++ b/api/tests/integration_tests/model_runtime/sagemaker/test_provider.py@@ -1,5 +1,3 @@-import os-import pytestfrom core.model_runtime.errors.validate import CredentialsValidateFailedErrordiff --git a/api/tests/integration_tests/model_runtime/sagemaker/test_text_embedding.py b/api/tests/integration_tests/model_runtime/sagemaker/test_text_embedding.pyindex e4e404c7a86..f77601eea2c 100644--- a/api/tests/integration_tests/model_runtime/sagemaker/test_text_embedding.py+++ b/api/tests/integration_tests/model_runtime/sagemaker/test_text_embedding.py@@ -1,5 +1,3 @@-import os-import pytestfrom core.model_runtime.entities.text_embedding_entities import TextEmbeddingResultdiff --git a/api/tests/integration_tests/model_runtime/stepfun/test_llm.py b/api/tests/integration_tests/model_runtime/stepfun/test_llm.pyindex c03b1bae1f1..f9afca6f594 100644--- a/api/tests/integration_tests/model_runtime/stepfun/test_llm.py+++ b/api/tests/integration_tests/model_runtime/stepfun/test_llm.py@@ -6,13 +6,11 @@ import pytestfrom core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDeltafrom core.model_runtime.entities.message_entities import (AssistantPromptMessage,- ImagePromptMessageContent,PromptMessageTool,SystemPromptMessage,- TextPromptMessageContent,UserPromptMessage,)-from core.model_runtime.entities.model_entities import AIModelEntity, ModelType+from core.model_runtime.entities.model_entities import AIModelEntityfrom core.model_runtime.errors.validate import CredentialsValidateFailedErrorfrom core.model_runtime.model_providers.stepfun.llm.llm import StepfunLargeLanguageModeldiff --git a/api/tests/integration_tests/model_runtime/togetherai/test_llm.py b/api/tests/integration_tests/model_runtime/togetherai/test_llm.pyindex 06ebc2a82dc..5787e1bf6a8 100644--- a/api/tests/integration_tests/model_runtime/togetherai/test_llm.py+++ b/api/tests/integration_tests/model_runtime/togetherai/test_llm.py@@ -6,7 +6,6 @@ import pytestfrom core.model_runtime.entities.llm_entities import LLMResult, LLMResultChunk, LLMResultChunkDeltafrom core.model_runtime.entities.message_entities import (AssistantPromptMessage,- PromptMessageTool,SystemPromptMessage,UserPromptMessage,)diff --git a/api/tests/integration_tests/model_runtime/upstage/test_llm.py b/api/tests/integration_tests/model_runtime/upstage/test_llm.pyindex bc7517acbe2..0f39e902f33 100644--- a/api/tests/integration_tests/model_runtime/upstage/test_llm.py+++ b/api/tests/integration_tests/model_runtime/upstage/test_llm.py@@ -10,9 +10,8 @@ from core.model_runtime.entities.message_entities import (SystemPromptMessage,UserPromptMessage,)-from core.model_runtime.entities.model_entities import AIModelEntity, ModelType+from core.model_runtime.entities.model_entities import AIModelEntityfrom core.model_runtime.errors.validate import CredentialsValidateFailedError-from core.model_runtime.model_providers.__base.large_language_model import LargeLanguageModelfrom core.model_runtime.model_providers.upstage.llm.llm import UpstageLargeLanguageModel"""FOR MOCK FIXTURES, DO NOT REMOVE"""diff --git a/api/tests/integration_tests/model_runtime/xinference/test_llm.py b/api/tests/integration_tests/model_runtime/xinference/test_llm.pyindex fb5e03855d2..5e4cde36389 100644--- a/api/tests/integration_tests/model_runtime/xinference/test_llm.py+++ b/api/tests/integration_tests/model_runtime/xinference/test_llm.py@@ -8,10 +8,8 @@ from core.model_runtime.entities.message_entities import (AssistantPromptMessage,PromptMessageTool,SystemPromptMessage,- TextPromptMessageContent,UserPromptMessage,)-from core.model_runtime.entities.model_entities import AIModelEntityfrom core.model_runtime.errors.validate import CredentialsValidateFailedErrorfrom core.model_runtime.model_providers.xinference.llm.llm import XinferenceAILargeLanguageModeldiff --git a/api/tests/integration_tests/vdb/pgvector/test_pgvector.py b/api/tests/integration_tests/vdb/pgvector/test_pgvector.pyindex 72efdc2780e..3d2cfde5d1d 100644--- a/api/tests/integration_tests/vdb/pgvector/test_pgvector.py+++ b/api/tests/integration_tests/vdb/pgvector/test_pgvector.py@@ -1,5 +1,4 @@from core.rag.datasource.vdb.pgvector.pgvector import PGVector, PGVectorConfig-from core.rag.models.document import Documentfrom tests.integration_tests.vdb.test_vector_store import (AbstractVectorTest,get_example_text,diff --git a/api/tests/integration_tests/vdb/test_vector_store.py b/api/tests/integration_tests/vdb/test_vector_store.pyindex a11cd225b3b..50519e2052c 100644--- a/api/tests/integration_tests/vdb/test_vector_store.py+++ b/api/tests/integration_tests/vdb/test_vector_store.py@@ -1,4 +1,3 @@-import randomimport uuidfrom unittest.mock import MagicMockdiff --git a/api/tests/integration_tests/workflow/nodes/__mock/code_executor.py b/api/tests/integration_tests/workflow/nodes/__mock/code_executor.pyindex 6fb8c86b82a..30414811ea7 100644--- a/api/tests/integration_tests/workflow/nodes/__mock/code_executor.py+++ b/api/tests/integration_tests/workflow/nodes/__mock/code_executor.py@@ -1,5 +1,5 @@import os-from typing import Literal, Optional+from typing import Literalimport pytestfrom _pytest.monkeypatch import MonkeyPatchdiff --git a/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.py b/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.pyindex 88435c40227..4c695f74433 100644--- a/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.py+++ b/api/tests/integration_tests/workflow/nodes/test_parameter_extractor.py@@ -1,4 +1,3 @@-import jsonimport osimport timeimport uuiddiff --git a/api/tests/unit_tests/core/app/segments/test_variables.py b/api/tests/unit_tests/core/app/segments/test_variables.pyindex b3f0ae626cf..6179675cde7 100644--- a/api/tests/unit_tests/core/app/segments/test_variables.py+++ b/api/tests/unit_tests/core/app/segments/test_variables.py@@ -2,7 +2,6 @@ import pytestfrom pydantic import ValidationErrorfrom core.app.segments import (- ArrayAnyVariable,FloatVariable,IntegerVariable,ObjectVariable,diff --git a/api/tests/unit_tests/core/rag/extractor/firecrawl/test_firecrawl.py b/api/tests/unit_tests/core/rag/extractor/firecrawl/test_firecrawl.pyindex d5a1d8f436c..8fcdf2e8e53 100644--- a/api/tests/unit_tests/core/rag/extractor/firecrawl/test_firecrawl.py+++ b/api/tests/unit_tests/core/rag/extractor/firecrawl/test_firecrawl.py@@ -1,9 +1,6 @@import os-from unittest import mockfrom core.rag.extractor.firecrawl.firecrawl_app import FirecrawlApp-from core.rag.extractor.firecrawl.firecrawl_web_extractor import FirecrawlWebExtractor-from core.rag.models.document import Documentfrom tests.unit_tests.core.rag.extractor.test_notion_extractor import _mock_response