Merge branch 'main' into feat/plugins

pull/12372/head
Yi 1 year ago
commit d43b2c62f5

@ -177,7 +177,7 @@ class EasyUIBasedGenerateTaskPipeline(BasedGenerateTaskPipeline, MessageCycleMan
else: else:
continue continue
raise Exception("Queue listening stopped unexpectedly.") raise RuntimeError("queue listening stopped unexpectedly.")
def _to_stream_response( def _to_stream_response(
self, generator: Generator[StreamResponse, None, None] self, generator: Generator[StreamResponse, None, None]

@ -0,0 +1,17 @@
class TaskPipilineError(ValueError):
pass
class RecordNotFoundError(TaskPipilineError):
def __init__(self, record_name: str, record_id: str):
super().__init__(f"{record_name} with id {record_id} not found")
class WorkflowRunNotFoundError(RecordNotFoundError):
def __init__(self, workflow_run_id: str):
super().__init__("WorkflowRun", workflow_run_id)
class WorkflowNodeExecutionNotFoundError(RecordNotFoundError):
def __init__(self, workflow_node_execution_id: str):
super().__init__("WorkflowNodeExecution", workflow_node_execution_id)

@ -58,6 +58,8 @@ from models.workflow import (
WorkflowRunStatus, WorkflowRunStatus,
) )
from .exc import WorkflowNodeExecutionNotFoundError, WorkflowRunNotFoundError
class WorkflowCycleManage: class WorkflowCycleManage:
_application_generate_entity: Union[AdvancedChatAppGenerateEntity, WorkflowAppGenerateEntity] _application_generate_entity: Union[AdvancedChatAppGenerateEntity, WorkflowAppGenerateEntity]
@ -898,7 +900,7 @@ class WorkflowCycleManage:
workflow_run = db.session.query(WorkflowRun).filter(WorkflowRun.id == workflow_run_id).first() workflow_run = db.session.query(WorkflowRun).filter(WorkflowRun.id == workflow_run_id).first()
if not workflow_run: if not workflow_run:
raise Exception(f"Workflow run not found: {workflow_run_id}") raise WorkflowRunNotFoundError(workflow_run_id)
return workflow_run return workflow_run
@ -911,6 +913,6 @@ class WorkflowCycleManage:
workflow_node_execution = self._wip_workflow_node_executions.get(node_execution_id) workflow_node_execution = self._wip_workflow_node_executions.get(node_execution_id)
if not workflow_node_execution: if not workflow_node_execution:
raise Exception(f"Workflow node execution not found: {node_execution_id}") raise WorkflowNodeExecutionNotFoundError(node_execution_id)
return workflow_node_execution return workflow_node_execution

@ -157,7 +157,6 @@ class HuggingfaceTeiTextEmbeddingModel(TextEmbeddingModel):
headers["Authorization"] = f"Bearer {api_key}" headers["Authorization"] = f"Bearer {api_key}"
extra_args = TeiHelper.get_tei_extra_parameter(server_url, model, headers) extra_args = TeiHelper.get_tei_extra_parameter(server_url, model, headers)
print(extra_args)
if extra_args.model_type != "embedding": if extra_args.model_type != "embedding":
raise CredentialsValidateFailedError("Current model is not a embedding model") raise CredentialsValidateFailedError("Current model is not a embedding model")

@ -90,5 +90,5 @@ class FileVariable(FileSegment, Variable):
pass pass
class ArrayFileVariable(ArrayFileSegment, Variable): class ArrayFileVariable(ArrayFileSegment, ArrayVariable):
pass pass

@ -612,8 +612,8 @@ class GraphEngine:
max_retries = node_instance.node_data.retry_config.max_retries max_retries = node_instance.node_data.retry_config.max_retries
retry_interval = node_instance.node_data.retry_config.retry_interval_seconds retry_interval = node_instance.node_data.retry_config.retry_interval_seconds
retries = 0 retries = 0
shoudl_continue_retry = True should_continue_retry = True
while shoudl_continue_retry and retries <= max_retries: while should_continue_retry and retries <= max_retries:
try: try:
# run node # run node
retry_start_at = datetime.now(UTC).replace(tzinfo=None) retry_start_at = datetime.now(UTC).replace(tzinfo=None)
@ -692,7 +692,7 @@ class GraphEngine:
parent_parallel_id=parent_parallel_id, parent_parallel_id=parent_parallel_id,
parent_parallel_start_node_id=parent_parallel_start_node_id, parent_parallel_start_node_id=parent_parallel_start_node_id,
) )
shoudl_continue_retry = False should_continue_retry = False
else: else:
yield NodeRunFailedEvent( yield NodeRunFailedEvent(
error=route_node_state.failed_reason or "Unknown error.", error=route_node_state.failed_reason or "Unknown error.",
@ -706,7 +706,7 @@ class GraphEngine:
parent_parallel_id=parent_parallel_id, parent_parallel_id=parent_parallel_id,
parent_parallel_start_node_id=parent_parallel_start_node_id, parent_parallel_start_node_id=parent_parallel_start_node_id,
) )
shoudl_continue_retry = False should_continue_retry = False
elif run_result.status == WorkflowNodeExecutionStatus.SUCCEEDED: elif run_result.status == WorkflowNodeExecutionStatus.SUCCEEDED:
if node_instance.should_continue_on_error and self.graph.edge_mapping.get( if node_instance.should_continue_on_error and self.graph.edge_mapping.get(
node_instance.node_id node_instance.node_id
@ -758,7 +758,7 @@ class GraphEngine:
parent_parallel_id=parent_parallel_id, parent_parallel_id=parent_parallel_id,
parent_parallel_start_node_id=parent_parallel_start_node_id, parent_parallel_start_node_id=parent_parallel_start_node_id,
) )
shoudl_continue_retry = False should_continue_retry = False
break break
elif isinstance(item, RunStreamChunkEvent): elif isinstance(item, RunStreamChunkEvent):

@ -2,6 +2,8 @@ import pytest
from pydantic import ValidationError from pydantic import ValidationError
from core.variables import ( from core.variables import (
ArrayFileVariable,
ArrayVariable,
FloatVariable, FloatVariable,
IntegerVariable, IntegerVariable,
ObjectVariable, ObjectVariable,
@ -81,3 +83,8 @@ def test_variable_to_object():
assert var.to_object() == 3.14 assert var.to_object() == 3.14
var = SecretVariable(name="secret", value="secret_value") var = SecretVariable(name="secret", value="secret_value")
assert var.to_object() == "secret_value" assert var.to_object() == "secret_value"
def test_array_file_variable_is_array_variable():
var = ArrayFileVariable(name="files", value=[])
assert isinstance(var, ArrayVariable)

@ -39,7 +39,7 @@ export default function Modal({
leaveFrom="opacity-100" leaveFrom="opacity-100"
leaveTo="opacity-0" leaveTo="opacity-0"
> >
<div className="fixed inset-0 bg-background-overlay-fullscreen" /> <div className="fixed inset-0 bg-background-overlay" />
</Transition.Child> </Transition.Child>
<div <div

Loading…
Cancel
Save