Skip to content

armgit / dify

Public Imported from GitHub
0

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.

Fix: Remove workflow/nodes from pyright exclusion (#26461)

Asuka Minatodecf0f3da0e3
diff --git a/api/core/workflow/nodes/http_request/executor.py b/api/core/workflow/nodes/http_request/executor.py
index c47ffb5ab08..d3d3571b444 100644
--- a/api/core/workflow/nodes/http_request/executor.py
+++ b/api/core/workflow/nodes/http_request/executor.py
@@ -87,7 +87,7 @@ class Executor:
node_data.authorization.config.api_key
).text
- self.url: str = node_data.url
+ self.url = node_data.url
self.method = node_data.method
self.auth = node_data.authorization
self.timeout = timeout
@@ -349,11 +349,10 @@ class Executor:
"timeout": (self.timeout.connect, self.timeout.read, self.timeout.write),
"ssl_verify": self.ssl_verify,
"follow_redirects": True,
- "max_retries": self.max_retries,
}
# request_args = {k: v for k, v in request_args.items() if v is not None}
try:
- response: httpx.Response = _METHOD_MAP[method_lc](**request_args)
+ response: httpx.Response = _METHOD_MAP[method_lc](**request_args, max_retries=self.max_retries)
except (ssrf_proxy.MaxRetriesExceededError, httpx.RequestError) as e:
raise HttpRequestNodeError(str(e)) from e
# FIXME: fix type ignore, this maybe httpx type issue
diff --git a/api/core/workflow/nodes/http_request/node.py b/api/core/workflow/nodes/http_request/node.py
index 826820a8e3e..20e1337ea7e 100644
--- a/api/core/workflow/nodes/http_request/node.py
+++ b/api/core/workflow/nodes/http_request/node.py
@@ -165,6 +165,8 @@ class HttpRequestNode(Node):
body_type = typed_node_data.body.type
data = typed_node_data.body.data
match body_type:
+ case "none":
+ pass
case "binary":
if len(data) != 1:
raise RequestBodyError("invalid body data, should have only one item")
diff --git a/api/core/workflow/nodes/if_else/if_else_node.py b/api/core/workflow/nodes/if_else/if_else_node.py
index 075f6f84445..7e3b6ecc1a7 100644
--- a/api/core/workflow/nodes/if_else/if_else_node.py
+++ b/api/core/workflow/nodes/if_else/if_else_node.py
@@ -83,7 +83,7 @@ class IfElseNode(Node):
else:
# TODO: Update database then remove this
# Fallback to old structure if cases are not defined
- input_conditions, group_result, final_result = _should_not_use_old_function( # ty: ignore [deprecated]
+ input_conditions, group_result, final_result = _should_not_use_old_function( # pyright: ignore [reportDeprecated]
condition_processor=condition_processor,
variable_pool=self.graph_runtime_state.variable_pool,
conditions=self._node_data.conditions or [],
diff --git a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py
index 1afb2e05b9e..b6128d3eab1 100644
--- a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py
+++ b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py
@@ -107,7 +107,7 @@ class KnowledgeRetrievalNode(Node):
graph_runtime_state=graph_runtime_state,
)
# LLM file outputs, used for MultiModal outputs.
- self._file_outputs: list[File] = []
+ self._file_outputs = []
if llm_file_saver is None:
llm_file_saver = FileSaverImpl(
diff --git a/api/core/workflow/nodes/list_operator/node.py b/api/core/workflow/nodes/list_operator/node.py
index 7a31d692210..3243b22d44d 100644
--- a/api/core/workflow/nodes/list_operator/node.py
+++ b/api/core/workflow/nodes/list_operator/node.py
@@ -161,6 +161,8 @@ class ListOperatorNode(Node):
elif isinstance(variable, ArrayFileSegment):
if isinstance(condition.value, str):
value = self.graph_runtime_state.variable_pool.convert_template(condition.value).text
+ elif isinstance(condition.value, bool):
+ raise ValueError(f"File filter expects a string value, got {type(condition.value)}")
else:
value = condition.value
filter_func = _get_file_filter_func(
diff --git a/api/core/workflow/nodes/llm/file_saver.py b/api/core/workflow/nodes/llm/file_saver.py
index 81f2df08913..3f32fa894ac 100644
--- a/api/core/workflow/nodes/llm/file_saver.py
+++ b/api/core/workflow/nodes/llm/file_saver.py
@@ -46,7 +46,7 @@ class LLMFileSaver(tp.Protocol):
dot (`.`). For example, `.py` and `.tar.gz` are both valid values, while `py`
and `tar.gz` are not.
"""
- pass
+ raise NotImplementedError()
def save_remote_url(self, url: str, file_type: FileType) -> File:
"""save_remote_url saves the file from a remote url returned by LLM.
@@ -56,7 +56,7 @@ class LLMFileSaver(tp.Protocol):
:param url: the url of the file.
:param file_type: the file type of the file, check `FileType` enum for reference.
"""
- pass
+ raise NotImplementedError()
EngineFactory: tp.TypeAlias = tp.Callable[[], Engine]
diff --git a/api/core/workflow/nodes/llm/node.py b/api/core/workflow/nodes/llm/node.py
index 36183bf8db9..47424763526 100644
--- a/api/core/workflow/nodes/llm/node.py
+++ b/api/core/workflow/nodes/llm/node.py
@@ -128,7 +128,7 @@ class LLMNode(Node):
graph_runtime_state=graph_runtime_state,
)
# LLM file outputs, used for MultiModal outputs.
- self._file_outputs: list[File] = []
+ self._file_outputs = []
if llm_file_saver is None:
llm_file_saver = FileSaverImpl(
@@ -166,6 +166,7 @@ class LLMNode(Node):
node_inputs: dict[str, Any] = {}
process_data: dict[str, Any] = {}
result_text = ""
+ clean_text = ""
usage = LLMUsage.empty_usage()
finish_reason = None
reasoning_content = None
diff --git a/api/core/workflow/nodes/question_classifier/question_classifier_node.py b/api/core/workflow/nodes/question_classifier/question_classifier_node.py
index 483cfff5741..592a6566fd8 100644
--- a/api/core/workflow/nodes/question_classifier/question_classifier_node.py
+++ b/api/core/workflow/nodes/question_classifier/question_classifier_node.py
@@ -68,7 +68,7 @@ class QuestionClassifierNode(Node):
graph_runtime_state=graph_runtime_state,
)
# LLM file outputs, used for MultiModal outputs.
- self._file_outputs: list[File] = []
+ self._file_outputs = []
if llm_file_saver is None:
llm_file_saver = FileSaverImpl(
@@ -111,9 +111,9 @@ class QuestionClassifierNode(Node):
query = variable.value if variable else None
variables = {"query": query}
# fetch model config
- model_instance, model_config = LLMNode._fetch_model_config(
- node_data_model=node_data.model,
+ model_instance, model_config = llm_utils.fetch_model_config(
tenant_id=self.tenant_id,
+ node_data_model=node_data.model,
)
# fetch memory
memory = llm_utils.fetch_memory(
diff --git a/api/pyrightconfig.json b/api/pyrightconfig.json
index caa194c9062..8c35dc7abb8 100644
--- a/api/pyrightconfig.json
+++ b/api/pyrightconfig.json
@@ -6,7 +6,6 @@
"migrations/",
"core/rag",
"extensions",
- "core/workflow/nodes",
"core/app/app_config/easy_ui_based_app/dataset"
],
"typeCheckingMode": "strict",