mirror of
https://github.com/langgenius/dify.git
synced 2026-03-13 11:07:40 +08:00
Extract validation logic from default.ts into shared utils.ts, enabling node card, panel, and checklist to share the same validation rules. Introduce provider-scoped model list queries to detect non-active model states (noConfigure, quotaExceeded, credentialRemoved, incompatible). Expand node card from 2 rows to 4 rows with per-row warning indicators, and add warningDot support to panel field titles.
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import type { NodeDefault } from '../../types'
|
|
import type { KnowledgeBaseNodeType } from './types'
|
|
import { BlockEnum } from '@/app/components/workflow/types'
|
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
|
import {
|
|
getKnowledgeBaseValidationIssue,
|
|
getKnowledgeBaseValidationMessage,
|
|
} from './utils'
|
|
|
|
const metaData = genNodeMetaData({
|
|
sort: 3.1,
|
|
type: BlockEnum.KnowledgeBase,
|
|
isRequired: true,
|
|
isUndeletable: true,
|
|
isSingleton: true,
|
|
isTypeFixed: true,
|
|
})
|
|
const nodeDefault: NodeDefault<KnowledgeBaseNodeType> = {
|
|
metaData,
|
|
defaultValue: {
|
|
index_chunk_variable_selector: [],
|
|
keyword_number: 10,
|
|
retrieval_model: {
|
|
top_k: 3,
|
|
score_threshold_enabled: false,
|
|
score_threshold: 0.5,
|
|
},
|
|
},
|
|
checkValid(payload, t) {
|
|
const issue = getKnowledgeBaseValidationIssue(payload)
|
|
if (issue)
|
|
return { isValid: false, errorMessage: getKnowledgeBaseValidationMessage(issue, t) }
|
|
|
|
return {
|
|
isValid: true,
|
|
errorMessage: '',
|
|
}
|
|
},
|
|
}
|
|
|
|
export default nodeDefault
|