File list variables support simultaneous uploading of multiple file types such as document files, images, audio, and video files. When application users upload files, all files are stored in the same Array[File]
array-type variable, which is not conducive to subsequent individual file processing.
The
Array
data type means that the actual value of the variable could be [1.mp3, 2.png, 3.doc]. LLMs only support reading single values such as image files or text content as input variables and cannot directly read array variables.
The list operator can filter and extract attributes such as file format type, file name, and size, passing different format files to corresponding processing nodes to achieve precise control over different file processing flows.
For example, in an application that allows users to upload both document files and image files simultaneously, different files need to be sorted through the list operation node, with different files being handled by different processes.
List operation nodes are generally used to extract information from array variables, converting them into variable types that can be accepted by downstream nodes through setting conditions. Its structure is divided into input variables, filter conditions, sorting, taking the first N items, and output variables.
Input Variables
The list operation node only accepts variables with the following data structures:
Filter Conditions
Process arrays in input variables by adding filter conditions. Sort out all array variables that meet the conditions from the array, which can be understood as filtering the attributes of variables.
Example: Files may contain multiple dimensions of attributes, such as file name, file type, file size, etc. Filter conditions allow setting screening conditions to select and extract specific files from array variables.
Supports extracting the following variables:
Sorting
Provides the ability to sort arrays in input variables, supporting sorting based on file attributes.
This option is often used in conjunction with first_record and last_record in output variables.
Take First N Items
You can choose a value between 1-20, used to select the first n items of the array variable.
Output Variables
Array elements that meet all filter conditions. Filter conditions, sorting, and limitations can be enabled separately. If enabled simultaneously, array elements that meet all conditions are returned.
In file interaction Q&A scenarios, application users may upload document files or image files simultaneously. LLMs only support the ability to recognize image files and do not support reading document files. At this time, the List Operation node is needed to preprocess the array of file variables and send different file types to corresponding processing nodes. The orchestration steps are as follows:
After the application user uploads both document files and images, document files are automatically diverted to the doc extractor node, and image files are automatically diverted to the LLM node to achieve joint processing of mixed files.