From 1607fcfaa73899d00cbd91dad76eea9aa665c6ae Mon Sep 17 00:00:00 2001 From: jyong Date: Tue, 19 Mar 2024 17:18:29 +0800 Subject: [PATCH] fix knowledge single retrieve when function call response is none --- .../question_classifier/template_prompts.py | 8 +++---- .../nodes/variable_assigner/entities.py | 2 +- .../variable_assigner_node.py | 22 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/api/core/workflow/nodes/question_classifier/template_prompts.py b/api/core/workflow/nodes/question_classifier/template_prompts.py index 4b55093968..672d373741 100644 --- a/api/core/workflow/nodes/question_classifier/template_prompts.py +++ b/api/core/workflow/nodes/question_classifier/template_prompts.py @@ -50,11 +50,11 @@ The input text is in the variable text_field. Categories are specified as a comm DO NOT include anything other than the JSON array in your response. ### Example Input: -{"input_text": ["I recently had a great experience with your company. The service was prompt and the staff was very friendly."],"categories": ["Customer Service, Satisfaction, Sales, Product"], "classification_instructions": ["classify the text based on the feedback provided by customer"]} -{"input_text": ["bad service, slow to bring the food"],"categories": ["Food Quality, Experience, Price" ], "classification_instructions": []} +{{"input_text": ["I recently had a great experience with your company. The service was prompt and the staff was very friendly."],"categories": ["Customer Service, Satisfaction, Sales, Product"], "classification_instructions": ["classify the text based on the feedback provided by customer"]}} +{{"input_text": ["bad service, slow to bring the food"],"categories": ["Food Quality, Experience, Price" ], "classification_instructions": []}} Output: -{"keywords": ["recently", "great experience", "company", "service", "prompt", "staff", "friendly"],"categories": ["Customer Service"]} -{"keywords": ["bad service", "slow", "food", "tip", "terrible", "waitresses"],"categories": ["Experience""]} +{{"keywords": ["recently", "great experience", "company", "service", "prompt", "staff", "friendly"],"categories": ["Customer Service"]}} +{{"keywords": ["bad service", "slow", "food", "tip", "terrible", "waitresses"],"categories": ["Experience""]}} ### Memory Here is the chat histories between human and assistant, inside XML tags. ### User Input diff --git a/api/core/workflow/nodes/variable_assigner/entities.py b/api/core/workflow/nodes/variable_assigner/entities.py index 8a205810e0..035618bd66 100644 --- a/api/core/workflow/nodes/variable_assigner/entities.py +++ b/api/core/workflow/nodes/variable_assigner/entities.py @@ -9,4 +9,4 @@ class VariableAssignerNodeData(BaseNodeData): """ type: str = 'variable-assigner' output_type: str - variables: list[str] + variables: list[list[str]] diff --git a/api/core/workflow/nodes/variable_assigner/variable_assigner_node.py b/api/core/workflow/nodes/variable_assigner/variable_assigner_node.py index b1a84b2603..660011a082 100644 --- a/api/core/workflow/nodes/variable_assigner/variable_assigner_node.py +++ b/api/core/workflow/nodes/variable_assigner/variable_assigner_node.py @@ -14,15 +14,19 @@ class VariableAssignerNode(BaseNode): def _run(self, variable_pool: VariablePool) -> NodeRunResult: node_data: VariableAssignerNodeData = cast(self._node_data_cls, self.node_data) - value = variable_pool.get_variable_value(node_data.variables) - variable_pool.append_variable( - node_id=self.node_id, - variable_key_list=node_data.variables, - value=value - ) - outputs = { - "output": value - } + outputs = {} + for variable in node_data.variables: + value = variable_pool.get_variable_value(variable) + if value: + variable_pool.append_variable( + node_id=self.node_id, + variable_key_list=variable, + value=value + ) + outputs = { + "output": value + } + break return NodeRunResult( status=WorkflowNodeExecutionStatus.SUCCEEDED,