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