dify/web/app/components/workflow/nodes/llm/utils.ts

25 lines
780 B
TypeScript
Raw Normal View History

2025-03-05 11:52:04 +08:00
import { ArrayType, Type } from './types'
import type { Field, LLMNodeType } from './types'
export const checkNodeValid = (payload: LLMNodeType) => {
return true
}
2025-03-05 11:52:04 +08:00
export const getFieldType = (field: Field) => {
const { type, items } = field
if (type !== Type.array || !items)
return type
return ArrayType[items.type]
}
export const getHasChildren = (schema: Field) => {
const complexTypes = [Type.object, Type.array]
if (!complexTypes.includes(schema.type))
return false
if (schema.type === Type.object)
return schema.properties && Object.keys(schema.properties).length > 0
if (schema.type === Type.array)
return schema.items && schema.items.type === Type.object && schema.items.properties && Object.keys(schema.items.properties).length > 0
}