Skip to content

Commit

Permalink
Fix/incorrect code template (#7490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly authored Aug 21, 2024
1 parent 85fc0fd commit a02118d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions api/core/helper/code_executor/code_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from threading import Lock
from typing import Literal, Optional

from httpx import get, post
from httpx import Timeout, get, post
from pydantic import BaseModel
from yarl import URL

Expand All @@ -21,7 +21,7 @@
CODE_EXECUTION_ENDPOINT = dify_config.CODE_EXECUTION_ENDPOINT
CODE_EXECUTION_API_KEY = dify_config.CODE_EXECUTION_API_KEY

CODE_EXECUTION_TIMEOUT = (10, 60)
CODE_EXECUTION_TIMEOUT = Timeout(connect=10, write=10, read=60, pool=None)

class CodeExecutionException(Exception):
pass
Expand Down Expand Up @@ -116,7 +116,7 @@ def execute_code(cls,
if response.data.error:
raise CodeExecutionException(response.data.error)

return response.data.stdout
return response.data.stdout or ''

@classmethod
def execute_workflow_code_template(cls, language: CodeLanguage, code: str, inputs: dict, dependencies: Optional[list[CodeDependency]] = None) -> dict:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_language() -> str:
def get_default_code(cls) -> str:
return dedent(
"""
def main(arg1: int, arg2: int) -> dict:
def main(arg1: str, arg2: str) -> dict:
return {
"result": arg1 + arg2,
}
Expand Down
5 changes: 2 additions & 3 deletions api/core/workflow/nodes/code/code_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class CodeNode(BaseNode):
_node_data_cls = CodeNodeData
node_type = NodeType.CODE
_node_type = NodeType.CODE

@classmethod
def get_default_config(cls, filters: Optional[dict] = None) -> dict:
Expand All @@ -48,8 +48,7 @@ def _run(self, variable_pool: VariablePool) -> NodeRunResult:
:param variable_pool: variable pool
:return:
"""
node_data = self.node_data
node_data: CodeNodeData = cast(self._node_data_cls, node_data)
node_data = cast(CodeNodeData, self.node_data)

# Get code language
code_language = node_data.code_language
Expand Down

0 comments on commit a02118d

Please sign in to comment.