mirror of https://github.com/langgenius/dify.git
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { type NodeDefault, PromptRole } from '../../types'
|
|
import type { LLMNodeType } from './types'
|
|
import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants'
|
|
|
|
const nodeDefault: NodeDefault<LLMNodeType> = {
|
|
defaultValue: {
|
|
model: {
|
|
provider: '',
|
|
name: '',
|
|
mode: 'chat',
|
|
completion_params: {
|
|
temperature: 0.7,
|
|
},
|
|
},
|
|
variables: [],
|
|
prompt_template: [{
|
|
role: PromptRole.system,
|
|
text: '',
|
|
}],
|
|
context: {
|
|
enabled: false,
|
|
variable_selector: [],
|
|
},
|
|
vision: {
|
|
enabled: false,
|
|
},
|
|
},
|
|
getAvailablePrevNodes(isChatMode: boolean) {
|
|
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
|
|
return nodes
|
|
},
|
|
getAvailableNextNodes(isChatMode: boolean) {
|
|
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
|
|
return nodes
|
|
},
|
|
checkValid(payload: LLMNodeType) {
|
|
let isValid = true
|
|
let errorMessages = ''
|
|
if (payload.type) {
|
|
isValid = true
|
|
errorMessages = ''
|
|
}
|
|
return {
|
|
isValid,
|
|
errorMessage: errorMessages,
|
|
}
|
|
},
|
|
}
|
|
|
|
export default nodeDefault
|