mirror of https://github.com/langgenius/dify.git
feat: direct answer node
This commit is contained in:
parent
9c70befaf6
commit
c8ea6d7bfb
|
|
@ -43,7 +43,11 @@ const Page: FC = () => {
|
|||
<Workflow
|
||||
nodes={initialNodes}
|
||||
edges={initialEdges}
|
||||
selectedNodeId='3'// TODO: for debug. 3: llm.
|
||||
/*
|
||||
* TODO: for debug.
|
||||
* 2 directAnswer 3: llm
|
||||
*/
|
||||
selectedNodeId='2'
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import type { DirectAnswerNodeType } from './types'
|
||||
|
||||
export const mockData: DirectAnswerNodeType = {
|
||||
title: 'Test',
|
||||
desc: 'Test',
|
||||
type: 'Test',
|
||||
variables: [
|
||||
{
|
||||
variable: 'age',
|
||||
value_selector: ['bbb', 'b', 'c'],
|
||||
},
|
||||
],
|
||||
answer: 'Sorry, I cannot answer this question.',
|
||||
}
|
||||
|
|
@ -1,8 +1,21 @@
|
|||
import type { FC } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { mockData } from './mock'
|
||||
|
||||
const Node: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>directAnswer</div>
|
||||
<div className='px-3'>
|
||||
<div className='px-[5px] py-[3px] bg-gray-100 rounded-md'>
|
||||
<div className='leading-4 text-[10px] font-medium text-gray-500 uppercase'>
|
||||
{t('workflow.nodes.directAnswer.answer')}
|
||||
</div>
|
||||
<div className='leading-4 text-xs font-normal text-gray-700'>
|
||||
{mockData.answer}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
import type { CommonNodeType, Variable } from '@/app/components/workflow/types'
|
||||
|
||||
export type DirectAnswerNodeType = CommonNodeType & {
|
||||
variables: Variable[]
|
||||
answer: string
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
import { MemoryRole } from '../../types'
|
||||
import type { LLMNodeData } from './types'
|
||||
import type { LLMNodeType } from './types'
|
||||
import { Resolution } from '@/types/app'
|
||||
|
||||
export const mockLLMNodeData: LLMNodeData = {
|
||||
export const mockData: LLMNodeType = {
|
||||
title: 'Test',
|
||||
desc: 'Test',
|
||||
type: 'Test',
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import type { FC } from 'react'
|
||||
import { mockLLMNodeData } from './mock'
|
||||
import { mockData } from './mock'
|
||||
import {
|
||||
useTextGenerationCurrentProviderAndModelAndModelList,
|
||||
} from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector'
|
||||
|
||||
const Node: FC = () => {
|
||||
const { provider, name: modelId } = mockLLMNodeData.model
|
||||
const { provider, name: modelId } = mockData.model
|
||||
const {
|
||||
|
||||
textGenerationModelList,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import type { FC } from 'react'
|
|||
import { useTranslation } from 'react-i18next'
|
||||
import VarList from '../_base/components/variable/var-list'
|
||||
import useConfig from './use-config'
|
||||
import { mockLLMNodeData } from './mock'
|
||||
import { mockData } from './mock'
|
||||
import Field from '@/app/components/workflow/nodes/_base/components/field'
|
||||
import AddButton from '@/app/components/base/button/add-button'
|
||||
import Split from '@/app/components/workflow/nodes/_base/components/split'
|
||||
|
|
@ -23,7 +23,7 @@ const Panel: FC = () => {
|
|||
handleVarListChange,
|
||||
handleAddVariable,
|
||||
toggleContextEnabled,
|
||||
} = useConfig(mockLLMNodeData)
|
||||
} = useConfig(mockData)
|
||||
const model = inputs.model
|
||||
// const modelMode = inputs.model?.mode
|
||||
// const isChatMode = modelMode === 'chat'
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
import type { Resolution } from '@/types/app'
|
||||
import type { Memory, ModelConfig, PromptItem, ValueSelector, Variable } from '@/app/components/workflow/types'
|
||||
import type { CommonNodeType, Memory, ModelConfig, PromptItem, ValueSelector, Variable } from '@/app/components/workflow/types'
|
||||
|
||||
export type LLMNodeData = {
|
||||
title: string
|
||||
desc: string
|
||||
type: string
|
||||
export type LLMNodeType = CommonNodeType & {
|
||||
model: ModelConfig
|
||||
variables: Variable[]
|
||||
prompt: PromptItem[] | PromptItem
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ export type NodeData = {
|
|||
}
|
||||
export type Node = ReactFlowNode<NodeData>
|
||||
|
||||
export type CommonNodeType = {
|
||||
title: string
|
||||
desc: string
|
||||
type: string
|
||||
}
|
||||
|
||||
export type ValueSelector = string[] // [nodeId, key | obj key path]
|
||||
|
||||
export type Variable = {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ const translation = {
|
|||
common: {
|
||||
outputVars: 'Output Variables',
|
||||
},
|
||||
directAnswer: {
|
||||
answer: 'Answer',
|
||||
inputVars: 'Input Variables',
|
||||
},
|
||||
llm: {
|
||||
model: 'model',
|
||||
variables: 'variables',
|
||||
|
|
|
|||
|
|
@ -1,11 +1,22 @@
|
|||
const translation = {
|
||||
nodes: {
|
||||
common: {
|
||||
outputVars: '输出变量',
|
||||
},
|
||||
directAnswer: {
|
||||
answer: '回复',
|
||||
inputVars: '输入变量',
|
||||
},
|
||||
llm: {
|
||||
model: '模型',
|
||||
variables: '变量',
|
||||
context: '上下文',
|
||||
prompt: '提示词',
|
||||
vision: '视觉',
|
||||
outputVars: {
|
||||
output: '生成内容',
|
||||
usage: '模型用量信息',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue