Co-authored-by: Joel <iamjoel007@gmail.com>tags/0.9.2
| # always enable retriever resource in debugger mode | # always enable retriever resource in debugger mode | ||||
| app_config.additional_features.show_retrieve_source = True | app_config.additional_features.show_retrieve_source = True | ||||
| workflow_run_id = str(uuid.uuid4()) | |||||
| # init application generate entity | # init application generate entity | ||||
| application_generate_entity = AdvancedChatAppGenerateEntity( | application_generate_entity = AdvancedChatAppGenerateEntity( | ||||
| task_id=str(uuid.uuid4()), | task_id=str(uuid.uuid4()), | ||||
| invoke_from=invoke_from, | invoke_from=invoke_from, | ||||
| extras=extras, | extras=extras, | ||||
| trace_manager=trace_manager, | trace_manager=trace_manager, | ||||
| workflow_run_id=workflow_run_id, | |||||
| ) | ) | ||||
| contexts.tenant_id.set(application_generate_entity.app_config.tenant_id) | contexts.tenant_id.set(application_generate_entity.app_config.tenant_id) | ||||
| SystemVariableKey.CONVERSATION_ID: self.conversation.id, | SystemVariableKey.CONVERSATION_ID: self.conversation.id, | ||||
| SystemVariableKey.USER_ID: user_id, | SystemVariableKey.USER_ID: user_id, | ||||
| SystemVariableKey.DIALOGUE_COUNT: conversation_dialogue_count, | SystemVariableKey.DIALOGUE_COUNT: conversation_dialogue_count, | ||||
| SystemVariableKey.APP_ID: app_config.app_id, | |||||
| SystemVariableKey.WORKFLOW_ID: app_config.workflow_id, | |||||
| SystemVariableKey.WORKFLOW_RUN_ID: self.application_generate_entity.workflow_run_id, | |||||
| } | } | ||||
| # init variable pool | # init variable pool |
| SystemVariableKey.FILES: application_generate_entity.files, | SystemVariableKey.FILES: application_generate_entity.files, | ||||
| SystemVariableKey.CONVERSATION_ID: conversation.id, | SystemVariableKey.CONVERSATION_ID: conversation.id, | ||||
| SystemVariableKey.USER_ID: user_id, | SystemVariableKey.USER_ID: user_id, | ||||
| SystemVariableKey.DIALOGUE_COUNT: conversation.dialogue_count, | |||||
| SystemVariableKey.APP_ID: application_generate_entity.app_config.app_id, | |||||
| SystemVariableKey.WORKFLOW_ID: workflow.id, | |||||
| SystemVariableKey.WORKFLOW_RUN_ID: application_generate_entity.workflow_run_id, | |||||
| } | } | ||||
| self._task_state = WorkflowTaskState() | self._task_state = WorkflowTaskState() |
| user_id = user.id if isinstance(user, Account) else user.session_id | user_id = user.id if isinstance(user, Account) else user.session_id | ||||
| trace_manager = TraceQueueManager(app_model.id, user_id) | trace_manager = TraceQueueManager(app_model.id, user_id) | ||||
| workflow_run_id = str(uuid.uuid4()) | |||||
| # init application generate entity | # init application generate entity | ||||
| application_generate_entity = WorkflowAppGenerateEntity( | application_generate_entity = WorkflowAppGenerateEntity( | ||||
| task_id=str(uuid.uuid4()), | task_id=str(uuid.uuid4()), | ||||
| invoke_from=invoke_from, | invoke_from=invoke_from, | ||||
| call_depth=call_depth, | call_depth=call_depth, | ||||
| trace_manager=trace_manager, | trace_manager=trace_manager, | ||||
| workflow_run_id=workflow_run_id, | |||||
| ) | ) | ||||
| contexts.tenant_id.set(application_generate_entity.app_config.tenant_id) | contexts.tenant_id.set(application_generate_entity.app_config.tenant_id) | ||||
| system_inputs = { | system_inputs = { | ||||
| SystemVariableKey.FILES: files, | SystemVariableKey.FILES: files, | ||||
| SystemVariableKey.USER_ID: user_id, | SystemVariableKey.USER_ID: user_id, | ||||
| SystemVariableKey.APP_ID: app_config.app_id, | |||||
| SystemVariableKey.WORKFLOW_ID: app_config.workflow_id, | |||||
| SystemVariableKey.WORKFLOW_RUN_ID: self.application_generate_entity.workflow_run_id, | |||||
| } | } | ||||
| variable_pool = VariablePool( | variable_pool = VariablePool( |
| self._workflow_system_variables = { | self._workflow_system_variables = { | ||||
| SystemVariableKey.FILES: application_generate_entity.files, | SystemVariableKey.FILES: application_generate_entity.files, | ||||
| SystemVariableKey.USER_ID: user_id, | SystemVariableKey.USER_ID: user_id, | ||||
| SystemVariableKey.APP_ID: application_generate_entity.app_config.app_id, | |||||
| SystemVariableKey.WORKFLOW_ID: workflow.id, | |||||
| SystemVariableKey.WORKFLOW_RUN_ID: application_generate_entity.workflow_run_id, | |||||
| } | } | ||||
| self._task_state = WorkflowTaskState() | self._task_state = WorkflowTaskState() |
| conversation_id: Optional[str] = None | conversation_id: Optional[str] = None | ||||
| parent_message_id: Optional[str] = None | parent_message_id: Optional[str] = None | ||||
| workflow_run_id: Optional[str] = None | |||||
| query: str | query: str | ||||
| class SingleIterationRunEntity(BaseModel): | class SingleIterationRunEntity(BaseModel): | ||||
| # app config | # app config | ||||
| app_config: WorkflowUIBasedAppConfig | app_config: WorkflowUIBasedAppConfig | ||||
| workflow_run_id: Optional[str] = None | |||||
| class SingleIterationRunEntity(BaseModel): | class SingleIterationRunEntity(BaseModel): | ||||
| """ | """ |
| # init workflow run | # init workflow run | ||||
| workflow_run = WorkflowRun() | workflow_run = WorkflowRun() | ||||
| workflow_run_id = self._workflow_system_variables[SystemVariableKey.WORKFLOW_RUN_ID] | |||||
| if workflow_run_id: | |||||
| workflow_run.id = workflow_run_id | |||||
| workflow_run.tenant_id = self._workflow.tenant_id | workflow_run.tenant_id = self._workflow.tenant_id | ||||
| workflow_run.app_id = self._workflow.app_id | workflow_run.app_id = self._workflow.app_id | ||||
| workflow_run.sequence_number = new_sequence_number | workflow_run.sequence_number = new_sequence_number |
| CONVERSATION_ID = "conversation_id" | CONVERSATION_ID = "conversation_id" | ||||
| USER_ID = "user_id" | USER_ID = "user_id" | ||||
| DIALOGUE_COUNT = "dialogue_count" | DIALOGUE_COUNT = "dialogue_count" | ||||
| APP_ID = "app_id" | |||||
| WORKFLOW_ID = "workflow_id" | |||||
| WORKFLOW_RUN_ID = "workflow_run_id" |
| const initialFeatures: FeaturesData = { | const initialFeatures: FeaturesData = { | ||||
| file: { | file: { | ||||
| image: { | image: { | ||||
| enabled: !!features.file_upload?.image.enabled, | |||||
| number_limits: features.file_upload?.image.number_limits || 3, | |||||
| transfer_methods: features.file_upload?.image.transfer_methods || ['local_file', 'remote_url'], | |||||
| enabled: !!features.file_upload?.image?.enabled, | |||||
| number_limits: features.file_upload?.image?.number_limits || 3, | |||||
| transfer_methods: features.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'], | |||||
| }, | }, | ||||
| }, | }, | ||||
| opening: { | opening: { |
| variable: 'sys.files', | variable: 'sys.files', | ||||
| type: VarType.arrayFile, | type: VarType.arrayFile, | ||||
| }) | }) | ||||
| res.vars.push({ | |||||
| variable: 'sys.app_id', | |||||
| type: VarType.string, | |||||
| }) | |||||
| res.vars.push({ | |||||
| variable: 'sys.workflow_id', | |||||
| type: VarType.string, | |||||
| }) | |||||
| res.vars.push({ | |||||
| variable: 'sys.workflow_run_id', | |||||
| type: VarType.string, | |||||
| }) | |||||
| break | break | ||||
| } | } | ||||
| </div> | </div> | ||||
| } | } | ||||
| /> | /> | ||||
| <VarItem | |||||
| readonly | |||||
| payload={{ | |||||
| variable: 'sys.app_id', | |||||
| } as any} | |||||
| rightContent={ | |||||
| <div className='text-xs font-normal text-gray-500'> | |||||
| String | |||||
| </div> | |||||
| } | |||||
| /> | |||||
| <VarItem | |||||
| readonly | |||||
| payload={{ | |||||
| variable: 'sys.workflow_id', | |||||
| } as any} | |||||
| rightContent={ | |||||
| <div className='text-xs font-normal text-gray-500'> | |||||
| String | |||||
| </div> | |||||
| } | |||||
| /> | |||||
| <VarItem | |||||
| readonly | |||||
| payload={{ | |||||
| variable: 'sys.workflow_run_id', | |||||
| } as any} | |||||
| rightContent={ | |||||
| <div className='text-xs font-normal text-gray-500'> | |||||
| String | |||||
| </div> | |||||
| } | |||||
| /> | |||||
| </div> | </div> | ||||
| </> | </> |