mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 15:35:56 +08:00
feat: list filter output
This commit is contained in:
parent
dc919c2a6c
commit
38edb06897
@ -368,6 +368,7 @@ export const SUPPORT_OUTPUT_VARS_NODE = [
|
||||
BlockEnum.Start, BlockEnum.LLM, BlockEnum.KnowledgeRetrieval, BlockEnum.Code, BlockEnum.TemplateTransform,
|
||||
BlockEnum.HttpRequest, BlockEnum.Tool, BlockEnum.VariableAssigner, BlockEnum.VariableAggregator, BlockEnum.QuestionClassifier,
|
||||
BlockEnum.ParameterExtractor, BlockEnum.Iteration,
|
||||
BlockEnum.ListFilter,
|
||||
]
|
||||
|
||||
export const LLM_OUTPUT_STRUCT: Var[] = [
|
||||
|
@ -13,6 +13,7 @@ import { VarType as ToolVarType } from '../../../tool/types'
|
||||
import type { ToolNodeType } from '../../../tool/types'
|
||||
import type { ParameterExtractorNodeType } from '../../../parameter-extractor/types'
|
||||
import type { IterationNodeType } from '../../../iteration/types'
|
||||
import type { ListFilterNodeType } from '../../../list-filter/types'
|
||||
import { BlockEnum, InputVarType, VarType } from '@/app/components/workflow/types'
|
||||
import type { StartNodeType } from '@/app/components/workflow/nodes/start/types'
|
||||
import type { ConversationVariable, EnvironmentVariable, Node, NodeOutPutVar, ValueSelector, Var } from '@/app/components/workflow/types'
|
||||
@ -75,6 +76,8 @@ const formatItem = (
|
||||
): NodeOutPutVar => {
|
||||
const { id, data } = item
|
||||
|
||||
console.log(data.type)
|
||||
|
||||
const res: NodeOutPutVar = {
|
||||
nodeId: id,
|
||||
title: data.title,
|
||||
@ -257,18 +260,21 @@ const formatItem = (
|
||||
}
|
||||
|
||||
case BlockEnum.ListFilter: {
|
||||
if (!(data as ListFilterNodeType).var_type)
|
||||
break
|
||||
|
||||
res.vars = [
|
||||
{
|
||||
variable: 'result',
|
||||
type: VarType.array, // TODO dyn value
|
||||
type: (data as ListFilterNodeType).var_type,
|
||||
},
|
||||
{
|
||||
variable: 'first_record',
|
||||
type: VarType.string, // TODO dyn value
|
||||
type: (data as ListFilterNodeType).item_var_type,
|
||||
},
|
||||
{
|
||||
variable: 'last_record',
|
||||
type: VarType.string, // TODO dyn value
|
||||
type: (data as ListFilterNodeType).item_var_type,
|
||||
},
|
||||
]
|
||||
break
|
||||
@ -1039,6 +1045,13 @@ export const getNodeOutputVars = (node: Node, isChatMode: boolean): ValueSelecto
|
||||
res.push([id, 'output'])
|
||||
break
|
||||
}
|
||||
|
||||
case BlockEnum.ListFilter: {
|
||||
res.push([id, 'result'])
|
||||
res.push([id, 'first_record'])
|
||||
res.push([id, 'last_record'])
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { ComparisonOperator } from '../if-else/types'
|
||||
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types'
|
||||
import type { CommonNodeType, ValueSelector, VarType } from '@/app/components/workflow/types'
|
||||
|
||||
export enum OrderBy {
|
||||
ASC = 'asc',
|
||||
@ -19,6 +19,8 @@ export type Condition = {
|
||||
|
||||
export type ListFilterNodeType = CommonNodeType & {
|
||||
variable: ValueSelector
|
||||
var_type: VarType // Cache for the type of output variable
|
||||
item_var_type: VarType // Cache for the type of output variable
|
||||
filter_by: Condition[]
|
||||
order_by: {
|
||||
enabled: boolean
|
||||
|
@ -77,6 +77,8 @@ const useConfig = (id: string, payload: ListFilterNodeType) => {
|
||||
const { varType, itemVarType } = getType(draft.variable)
|
||||
const isFileArray = varType === VarType.arrayFile
|
||||
|
||||
draft.var_type = varType
|
||||
draft.item_var_type = itemVarType
|
||||
draft.filter_by = [{
|
||||
key: isFileArray ? 'name' : '',
|
||||
comparison_operator: getOperators(itemVarType, isFileArray ? { key: 'name' } : undefined)[0],
|
||||
|
Loading…
x
Reference in New Issue
Block a user