mirror of https://github.com/langgenius/dify.git
fix: code
This commit is contained in:
parent
73c2b35dfe
commit
d8ab611480
|
|
@ -97,6 +97,7 @@ class WorkflowEventTriggerCallback(BaseWorkflowCallback):
|
|||
node_data: BaseNodeData,
|
||||
error: str,
|
||||
inputs: Optional[dict] = None,
|
||||
outputs: Optional[dict] = None,
|
||||
process_data: Optional[dict] = None) -> None:
|
||||
"""
|
||||
Workflow node execute failed
|
||||
|
|
@ -107,6 +108,7 @@ class WorkflowEventTriggerCallback(BaseWorkflowCallback):
|
|||
node_type=node_type,
|
||||
node_data=node_data,
|
||||
inputs=inputs,
|
||||
outputs=outputs,
|
||||
process_data=process_data,
|
||||
error=error
|
||||
),
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ class WorkflowEventTriggerCallback(BaseWorkflowCallback):
|
|||
node_data: BaseNodeData,
|
||||
error: str,
|
||||
inputs: Optional[dict] = None,
|
||||
outputs: Optional[dict] = None,
|
||||
process_data: Optional[dict] = None) -> None:
|
||||
"""
|
||||
Workflow node execute failed
|
||||
|
|
@ -106,6 +107,7 @@ class WorkflowEventTriggerCallback(BaseWorkflowCallback):
|
|||
node_type=node_type,
|
||||
node_data=node_data,
|
||||
inputs=inputs,
|
||||
outputs=outputs,
|
||||
process_data=process_data,
|
||||
error=error
|
||||
),
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ class QueueNodeFailedEvent(AppQueueEvent):
|
|||
node_data: BaseNodeData
|
||||
|
||||
inputs: Optional[dict] = None
|
||||
outputs: Optional[dict] = None
|
||||
process_data: Optional[dict] = None
|
||||
|
||||
error: str
|
||||
|
|
|
|||
|
|
@ -218,7 +218,11 @@ class WorkflowCycleManage:
|
|||
|
||||
def _workflow_node_execution_failed(self, workflow_node_execution: WorkflowNodeExecution,
|
||||
start_at: float,
|
||||
error: str) -> WorkflowNodeExecution:
|
||||
error: str,
|
||||
inputs: Optional[dict] = None,
|
||||
process_data: Optional[dict] = None,
|
||||
outputs: Optional[dict] = None,
|
||||
) -> WorkflowNodeExecution:
|
||||
"""
|
||||
Workflow node execution failed
|
||||
:param workflow_node_execution: workflow node execution
|
||||
|
|
@ -230,6 +234,9 @@ class WorkflowCycleManage:
|
|||
workflow_node_execution.error = error
|
||||
workflow_node_execution.elapsed_time = time.perf_counter() - start_at
|
||||
workflow_node_execution.finished_at = datetime.utcnow()
|
||||
workflow_node_execution.inputs = json.dumps(inputs) if inputs else None
|
||||
workflow_node_execution.process_data = json.dumps(process_data) if process_data else None
|
||||
workflow_node_execution.outputs = json.dumps(outputs) if outputs else None
|
||||
|
||||
db.session.commit()
|
||||
db.session.refresh(workflow_node_execution)
|
||||
|
|
@ -402,7 +409,10 @@ class WorkflowCycleManage:
|
|||
workflow_node_execution = self._workflow_node_execution_failed(
|
||||
workflow_node_execution=workflow_node_execution,
|
||||
start_at=current_node_execution.start_at,
|
||||
error=event.error
|
||||
error=event.error,
|
||||
inputs=event.inputs,
|
||||
process_data=event.process_data,
|
||||
outputs=event.outputs
|
||||
)
|
||||
|
||||
db.session.close()
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class CodeExecutor:
|
|||
response = response.json()
|
||||
except:
|
||||
raise CodeExecutionException('Failed to parse response')
|
||||
|
||||
|
||||
response = CodeExecutionResponse(**response)
|
||||
|
||||
if response.code != 0:
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class PythonTemplateTransformer(TemplateTransformer):
|
|||
:return:
|
||||
"""
|
||||
# extract result
|
||||
result = re.search(r'<<RESULT>>(.*)<<RESULT>>', response, re.DOTALL)
|
||||
result = re.search(r'<<RESULT>>(.*?)<<RESULT>>', response, re.DOTALL)
|
||||
if not result:
|
||||
raise ValueError('Failed to parse result')
|
||||
result = result.group(1)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ class BaseWorkflowCallback(ABC):
|
|||
node_data: BaseNodeData,
|
||||
error: str,
|
||||
inputs: Optional[dict] = None,
|
||||
outputs: Optional[dict] = None,
|
||||
process_data: Optional[dict] = None) -> None:
|
||||
"""
|
||||
Workflow node execute failed
|
||||
|
|
|
|||
|
|
@ -11,19 +11,19 @@ MAX_NUMBER = 2 ** 63 - 1
|
|||
MIN_NUMBER = -2 ** 63
|
||||
MAX_PRECISION = 20
|
||||
MAX_DEPTH = 5
|
||||
MAX_STRING_LENGTH = 1000
|
||||
MAX_STRING_LENGTH = 5000
|
||||
MAX_STRING_ARRAY_LENGTH = 30
|
||||
MAX_NUMBER_ARRAY_LENGTH = 1000
|
||||
|
||||
JAVASCRIPT_DEFAULT_CODE = """function main({arg1, arg2}) {
|
||||
return {
|
||||
result: args1 + args2
|
||||
result: arg1 + arg2
|
||||
}
|
||||
}"""
|
||||
|
||||
PYTHON_DEFAULT_CODE = """def main(arg1: int, arg2: int) -> dict:
|
||||
return {
|
||||
"result": args1 + args2,
|
||||
"result": arg1 + arg2,
|
||||
}"""
|
||||
|
||||
class CodeNode(BaseNode):
|
||||
|
|
|
|||
|
|
@ -429,6 +429,7 @@ class WorkflowEngineManager:
|
|||
node_data=node.node_data,
|
||||
error=node_run_result.error,
|
||||
inputs=node_run_result.inputs,
|
||||
outputs=node_run_result.outputs,
|
||||
process_data=node_run_result.process_data,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue