Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
c8ea6d7b
Commit
c8ea6d7b
authored
Feb 20, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: direct answer node
parent
9c70befa
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
68 additions
and
13 deletions
+68
-13
page.tsx
web/app/(commonLayout)/workflow/nodes/page.tsx
+5
-1
mock.ts
web/app/components/workflow/nodes/direct-answer/mock.ts
+14
-0
node.tsx
web/app/components/workflow/nodes/direct-answer/node.tsx
+14
-1
types.ts
web/app/components/workflow/nodes/direct-answer/types.ts
+6
-0
mock.ts
web/app/components/workflow/nodes/llm/mock.ts
+2
-2
node.tsx
web/app/components/workflow/nodes/llm/node.tsx
+2
-2
panel.tsx
web/app/components/workflow/nodes/llm/panel.tsx
+2
-2
types.ts
web/app/components/workflow/nodes/llm/types.ts
+2
-5
types.ts
web/app/components/workflow/types.ts
+6
-0
workflow.en.ts
web/i18n/lang/workflow.en.ts
+4
-0
workflow.zh.ts
web/i18n/lang/workflow.zh.ts
+11
-0
No files found.
web/app/(commonLayout)/workflow/nodes/page.tsx
View file @
c8ea6d7b
...
...
@@ -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
>
)
...
...
web/app/components/workflow/nodes/direct-answer/mock.ts
0 → 100644
View file @
c8ea6d7b
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.'
,
}
web/app/components/workflow/nodes/direct-answer/node.tsx
View file @
c8ea6d7b
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
>
)
}
...
...
web/app/components/workflow/nodes/direct-answer/types.ts
0 → 100644
View file @
c8ea6d7b
import
type
{
CommonNodeType
,
Variable
}
from
'@/app/components/workflow/types'
export
type
DirectAnswerNodeType
=
CommonNodeType
&
{
variables
:
Variable
[]
answer
:
string
}
web/app/components/workflow/nodes/llm/mock.ts
View file @
c8ea6d7b
import
{
MemoryRole
}
from
'../../types'
import
type
{
LLMNode
Data
}
from
'./types'
import
type
{
LLMNode
Type
}
from
'./types'
import
{
Resolution
}
from
'@/types/app'
export
const
mock
LLMNodeData
:
LLMNodeData
=
{
export
const
mock
Data
:
LLMNodeType
=
{
title
:
'Test'
,
desc
:
'Test'
,
type
:
'Test'
,
...
...
web/app/components/workflow/nodes/llm/node.tsx
View file @
c8ea6d7b
import
type
{
FC
}
from
'react'
import
{
mock
LLMNode
Data
}
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
}
=
mock
LLMNode
Data
.
model
const
{
provider
,
name
:
modelId
}
=
mockData
.
model
const
{
textGenerationModelList
,
...
...
web/app/components/workflow/nodes/llm/panel.tsx
View file @
c8ea6d7b
...
...
@@ -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
{
mock
LLMNode
Data
}
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
(
mock
LLMNode
Data
)
}
=
useConfig
(
mockData
)
const
model
=
inputs
.
model
// const modelMode = inputs.model?.mode
// const isChatMode = modelMode === 'chat'
...
...
web/app/components/workflow/nodes/llm/types.ts
View file @
c8ea6d7b
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
...
...
web/app/components/workflow/types.ts
View file @
c8ea6d7b
...
...
@@ -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
=
{
...
...
web/i18n/lang/workflow.en.ts
View file @
c8ea6d7b
...
...
@@ -3,6 +3,10 @@ const translation = {
common
:
{
outputVars
:
'Output Variables'
,
},
directAnswer
:
{
answer
:
'Answer'
,
inputVars
:
'Input Variables'
,
},
llm
:
{
model
:
'model'
,
variables
:
'variables'
,
...
...
web/i18n/lang/workflow.zh.ts
View file @
c8ea6d7b
const
translation
=
{
nodes
:
{
common
:
{
outputVars
:
'输出变量'
,
},
directAnswer
:
{
answer
:
'回复'
,
inputVars
:
'输入变量'
,
},
llm
:
{
model
:
'模型'
,
variables
:
'变量'
,
context
:
'上下文'
,
prompt
:
'提示词'
,
vision
:
'视觉'
,
outputVars
:
{
output
:
'生成内容'
,
usage
:
'模型用量信息'
,
},
},
},
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment