Commit 57e9e229 authored by Joel's avatar Joel

temp

parent 90c8d9d2
...@@ -32,7 +32,7 @@ const allMockData = { ...@@ -32,7 +32,7 @@ const allMockData = {
[BlockEnum.End]: EndNodeMock, [BlockEnum.End]: EndNodeMock,
} }
const nodes = [ const nodes = [
BlockEnum.QuestionClassifier/* 5 */, BlockEnum.Start/* 1 */, BlockEnum.DirectAnswer/* 2 */, BlockEnum.LLM/* 3 */, BlockEnum.KnowledgeRetrieval/* 4 */, BlockEnum.Start/* 1 */, BlockEnum.QuestionClassifier/* 5 */, BlockEnum.DirectAnswer/* 2 */, BlockEnum.LLM/* 3 */, BlockEnum.KnowledgeRetrieval/* 4 */,
BlockEnum.IfElse/* 6 */, BlockEnum.Code/* 7 */, BlockEnum.TemplateTransform/* 8 */, BlockEnum.HttpRequest/* 9 */, BlockEnum.Tool/* 10 */, BlockEnum.IfElse/* 6 */, BlockEnum.Code/* 7 */, BlockEnum.TemplateTransform/* 8 */, BlockEnum.HttpRequest/* 9 */, BlockEnum.Tool/* 10 */,
BlockEnum.VariableAssigner/* 11 */, BlockEnum.End/* 12 */, BlockEnum.VariableAssigner/* 11 */, BlockEnum.End/* 12 */,
].map((item, i) => { ].map((item, i) => {
......
import { BlockEnum } from './types' import { BlockEnum } from './types'
import StartNodeDefault from './nodes/start/default'
import DirectAnswerDefault from './nodes/direct-answer/default'
import LLMDefault from './nodes/llm/default'
import KnowledgeRetrievalDefault from './nodes/knowledge-retrieval/default'
import QuestionClassifierDefault from './nodes/question-classifier/default'
import IfElseDefault from './nodes/if-else/default'
import CodeDefault from './nodes/code/default'
import TemplateTransformDefault from './nodes/template-transform/default'
import HttpRequestDefault from './nodes/http/default'
import ToolDefault from './nodes/tool/default'
import VariableAssignerDefault from './nodes/variable-assigner/default'
import EndNodeDefault from './nodes/end/default'
export const NodeInitialData = { export const NodeInitialData = {
[BlockEnum.Start]: { [BlockEnum.Start]: {
type: BlockEnum.Start, type: BlockEnum.Start,
title: '', title: '',
desc: '', desc: '',
variables: [], ...StartNodeDefault.defaultValue,
}, },
[BlockEnum.End]: { [BlockEnum.End]: {
type: BlockEnum.End, type: BlockEnum.End,
title: '', title: '',
desc: '', desc: '',
outputs: {}, ...EndNodeDefault.defaultValue,
}, },
[BlockEnum.DirectAnswer]: { [BlockEnum.DirectAnswer]: {
type: BlockEnum.DirectAnswer, type: BlockEnum.DirectAnswer,
title: '', title: '',
desc: '', desc: '',
variables: [], ...DirectAnswerDefault.defaultValue,
}, },
[BlockEnum.LLM]: { [BlockEnum.LLM]: {
type: BlockEnum.LLM, type: BlockEnum.LLM,
title: '', title: '',
desc: '', desc: '',
variables: [], variables: [],
...LLMDefault.defaultValue,
}, },
[BlockEnum.KnowledgeRetrieval]: { [BlockEnum.KnowledgeRetrieval]: {
type: BlockEnum.KnowledgeRetrieval, type: BlockEnum.KnowledgeRetrieval,
...@@ -32,9 +45,10 @@ export const NodeInitialData = { ...@@ -32,9 +45,10 @@ export const NodeInitialData = {
query_variable_selector: [], query_variable_selector: [],
dataset_ids: [], dataset_ids: [],
retrieval_mode: 'single', retrieval_mode: 'single',
...KnowledgeRetrievalDefault.defaultValue,
}, },
[BlockEnum.IfElse]: { [BlockEnum.IfElse]: {
targetBranches: [ _targetBranches: [
{ {
id: 'if-true', id: 'if-true',
name: 'IS TRUE', name: 'IS TRUE',
...@@ -49,6 +63,7 @@ export const NodeInitialData = { ...@@ -49,6 +63,7 @@ export const NodeInitialData = {
desc: '', desc: '',
logical_operator: 'and', logical_operator: 'and',
conditions: [], conditions: [],
...IfElseDefault.defaultValue,
}, },
[BlockEnum.Code]: { [BlockEnum.Code]: {
type: BlockEnum.Code, type: BlockEnum.Code,
...@@ -58,6 +73,7 @@ export const NodeInitialData = { ...@@ -58,6 +73,7 @@ export const NodeInitialData = {
code_language: 'python3', code_language: 'python3',
code: '', code: '',
outputs: [], outputs: [],
...CodeDefault.defaultValue,
}, },
[BlockEnum.TemplateTransform]: { [BlockEnum.TemplateTransform]: {
type: BlockEnum.TemplateTransform, type: BlockEnum.TemplateTransform,
...@@ -65,6 +81,7 @@ export const NodeInitialData = { ...@@ -65,6 +81,7 @@ export const NodeInitialData = {
desc: '', desc: '',
variables: [], variables: [],
template: '', template: '',
...TemplateTransformDefault.defaultValue,
}, },
[BlockEnum.QuestionClassifier]: { [BlockEnum.QuestionClassifier]: {
type: BlockEnum.QuestionClassifier, type: BlockEnum.QuestionClassifier,
...@@ -72,12 +89,14 @@ export const NodeInitialData = { ...@@ -72,12 +89,14 @@ export const NodeInitialData = {
desc: '', desc: '',
query_variable_selector: [], query_variable_selector: [],
topics: [], topics: [],
...QuestionClassifierDefault.defaultValue,
}, },
[BlockEnum.HttpRequest]: { [BlockEnum.HttpRequest]: {
type: BlockEnum.HttpRequest, type: BlockEnum.HttpRequest,
title: '', title: '',
desc: '', desc: '',
variables: [], variables: [],
...HttpRequestDefault.defaultValue,
}, },
[BlockEnum.VariableAssigner]: { [BlockEnum.VariableAssigner]: {
type: BlockEnum.VariableAssigner, type: BlockEnum.VariableAssigner,
...@@ -85,11 +104,13 @@ export const NodeInitialData = { ...@@ -85,11 +104,13 @@ export const NodeInitialData = {
desc: '', desc: '',
variables: [], variables: [],
output_type: '', output_type: '',
...VariableAssignerDefault.defaultValue,
}, },
[BlockEnum.Tool]: { [BlockEnum.Tool]: {
type: BlockEnum.Tool, type: BlockEnum.Tool,
title: '', title: '',
desc: '', desc: '',
...ToolDefault.defaultValue,
}, },
} }
......
...@@ -2,7 +2,10 @@ import type { NodeDefault } from '../../types' ...@@ -2,7 +2,10 @@ import type { NodeDefault } from '../../types'
import type { DirectAnswerNodeType } from './types' import type { DirectAnswerNodeType } from './types'
const nodeDefault: NodeDefault<DirectAnswerNodeType> = { const nodeDefault: NodeDefault<DirectAnswerNodeType> = {
defaultValue: {}, defaultValue: {
variables: [],
answer: '',
},
getAvailablePrevNodes() { getAvailablePrevNodes() {
return [] return []
}, },
......
...@@ -2,7 +2,9 @@ import type { NodeDefault } from '../../types' ...@@ -2,7 +2,9 @@ import type { NodeDefault } from '../../types'
import type { LLMNodeType } from './types' import type { LLMNodeType } from './types'
const nodeDefault: NodeDefault<LLMNodeType> = { const nodeDefault: NodeDefault<LLMNodeType> = {
defaultValue: {}, defaultValue: {
},
getAvailablePrevNodes() { getAvailablePrevNodes() {
return [] return []
}, },
......
...@@ -9,7 +9,7 @@ import type { NodeProps } from '@/app/components/workflow/types' ...@@ -9,7 +9,7 @@ import type { NodeProps } from '@/app/components/workflow/types'
const Node: FC<NodeProps<LLMNodeType>> = ({ const Node: FC<NodeProps<LLMNodeType>> = ({
data, data,
}) => { }) => {
const { provider, name: modelId } = data.model const { provider, name: modelId } = data.model || {}
const { const {
textGenerationModelList, textGenerationModelList,
} = useTextGenerationCurrentProviderAndModelAndModelList() } = useTextGenerationCurrentProviderAndModelAndModelList()
......
...@@ -51,8 +51,8 @@ const Panel: FC<NodeProps<LLMNodeType>> = ({ ...@@ -51,8 +51,8 @@ const Panel: FC<NodeProps<LLMNodeType>> = ({
isAdvancedMode={true} isAdvancedMode={true}
mode={model?.mode} mode={model?.mode}
provider={model?.provider} provider={model?.provider}
completionParams={model.completion_params} completionParams={model?.completion_params}
modelId={model.name} modelId={model?.name}
setModel={handleModelChanged} setModel={handleModelChanged}
onCompletionParamsChange={handleCompletionParamsChange} onCompletionParamsChange={handleCompletionParamsChange}
hideDebugWithMultipleModel hideDebugWithMultipleModel
...@@ -81,7 +81,7 @@ const Panel: FC<NodeProps<LLMNodeType>> = ({ ...@@ -81,7 +81,7 @@ const Panel: FC<NodeProps<LLMNodeType>> = ({
<VarReferencePicker <VarReferencePicker
readonly={readOnly} readonly={readOnly}
isShowNodeName isShowNodeName
value={inputs.context.variable_selector} value={inputs.context?.variable_selector || []}
onChange={handleContextVarChange} onChange={handleContextVarChange}
/> />
......
...@@ -2,7 +2,9 @@ import type { NodeDefault } from '../../types' ...@@ -2,7 +2,9 @@ import type { NodeDefault } from '../../types'
import type { StartNodeType } from './types' import type { StartNodeType } from './types'
const nodeDefault: NodeDefault<StartNodeType> = { const nodeDefault: NodeDefault<StartNodeType> = {
defaultValue: {}, defaultValue: {
variables: [],
},
getAvailablePrevNodes() { getAvailablePrevNodes() {
return [] return []
}, },
......
...@@ -10,7 +10,7 @@ const Node: FC<NodeProps<StartNodeType>> = ({ ...@@ -10,7 +10,7 @@ const Node: FC<NodeProps<StartNodeType>> = ({
data, data,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const { variables = [] } = data const { variables } = data
return ( return (
<div className='px-3'> <div className='px-3'>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment