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
c441a848
Commit
c441a848
authored
Feb 20, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: question classify node
parent
f14a5c73
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
111 additions
and
13 deletions
+111
-13
page.tsx
web/app/(commonLayout)/workflow/nodes/page.tsx
+3
-3
info-panel.tsx
...components/workflow/nodes/_base/components/info-panel.tsx
+27
-0
node.tsx
web/app/components/workflow/nodes/direct-answer/node.tsx
+2
-8
node.tsx
web/app/components/workflow/nodes/llm/node.tsx
+0
-1
mock.ts
...app/components/workflow/nodes/question-classifier/mock.ts
+37
-0
node.tsx
...pp/components/workflow/nodes/question-classifier/node.tsx
+27
-1
types.ts
...pp/components/workflow/nodes/question-classifier/types.ts
+15
-0
No files found.
web/app/(commonLayout)/workflow/nodes/page.tsx
View file @
c441a848
...
@@ -6,7 +6,7 @@ import Workflow from '@/app/components/workflow'
...
@@ -6,7 +6,7 @@ import Workflow from '@/app/components/workflow'
import
{
BlockEnum
}
from
'@/app/components/workflow/types'
import
{
BlockEnum
}
from
'@/app/components/workflow/types'
const
nodes
=
[
const
nodes
=
[
BlockEnum
.
Start
,
BlockEnum
.
DirectAnswer
,
BlockEnum
.
LLM
,
BlockEnum
.
KnowledgeRetrieval
,
BlockEnum
.
QuestionClassifier
,
BlockEnum
.
Start
,
BlockEnum
.
DirectAnswer
,
BlockEnum
.
LLM
,
BlockEnum
.
KnowledgeRetrieval
,
BlockEnum
.
QuestionClassifier
,
BlockEnum
.
QuestionClassifier
,
BlockEnum
.
IfElse
,
BlockEnum
.
Code
,
BlockEnum
.
TemplateTransform
,
BlockEnum
.
HttpRequest
,
BlockEnum
.
IfElse
,
BlockEnum
.
Code
,
BlockEnum
.
TemplateTransform
,
BlockEnum
.
HttpRequest
,
BlockEnum
.
Tool
,
BlockEnum
.
Tool
,
].
map
((
item
,
i
)
=>
({
].
map
((
item
,
i
)
=>
({
id
:
`
${
i
+
1
}
`
,
id
:
`
${
i
+
1
}
`
,
...
@@ -45,9 +45,9 @@ const Page: FC = () => {
...
@@ -45,9 +45,9 @@ const Page: FC = () => {
edges=
{
initialEdges
}
edges=
{
initialEdges
}
/*
/*
* TODO: for debug.
* TODO: for debug.
* 2 directAnswer 3: llm
* 2 directAnswer 3: llm
5: questionClassifier
*/
*/
selectedNodeId=
'
2
'
selectedNodeId=
'
5
'
/>
/>
</
div
>
</
div
>
)
)
...
...
web/app/components/workflow/nodes/_base/components/info-panel.tsx
0 → 100644
View file @
c441a848
'use client'
import
type
{
FC
}
from
'react'
import
React
from
'react'
type
Props
=
{
title
:
string
content
:
string
}
const
InfoPanel
:
FC
<
Props
>
=
({
title
,
content
,
})
=>
{
return
(
<
div
>
<
div
className=
'px-[5px] py-[3px] bg-gray-100 rounded-md'
>
<
div
className=
'leading-4 text-[10px] font-medium text-gray-500 uppercase'
>
{
title
}
</
div
>
<
div
className=
'leading-4 text-xs font-normal text-gray-700'
>
{
content
}
</
div
>
</
div
>
</
div
>
)
}
export
default
React
.
memo
(
InfoPanel
)
web/app/components/workflow/nodes/direct-answer/node.tsx
View file @
c441a848
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
InfoPanel
from
'../_base/components/info-panel'
import
{
mockData
}
from
'./mock'
import
{
mockData
}
from
'./mock'
const
Node
:
FC
=
()
=>
{
const
Node
:
FC
=
()
=>
{
...
@@ -7,14 +8,7 @@ const Node: FC = () => {
...
@@ -7,14 +8,7 @@ const Node: FC = () => {
return
(
return
(
<
div
className=
'px-3'
>
<
div
className=
'px-3'
>
<
div
className=
'px-[5px] py-[3px] bg-gray-100 rounded-md'
>
<
InfoPanel
title=
{
t
(
'workflow.nodes.directAnswer.answer'
)
}
content=
{
mockData
.
answer
}
/>
<
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
>
</
div
>
)
)
}
}
...
...
web/app/components/workflow/nodes/llm/node.tsx
View file @
c441a848
...
@@ -8,7 +8,6 @@ import ModelSelector from '@/app/components/header/account-setting/model-provide
...
@@ -8,7 +8,6 @@ import ModelSelector from '@/app/components/header/account-setting/model-provide
const
Node
:
FC
=
()
=>
{
const
Node
:
FC
=
()
=>
{
const
{
provider
,
name
:
modelId
}
=
mockData
.
model
const
{
provider
,
name
:
modelId
}
=
mockData
.
model
const
{
const
{
textGenerationModelList
,
textGenerationModelList
,
}
=
useTextGenerationCurrentProviderAndModelAndModelList
()
}
=
useTextGenerationCurrentProviderAndModelAndModelList
()
return
(
return
(
...
...
web/app/components/workflow/nodes/question-classifier/mock.ts
0 → 100644
View file @
c441a848
import
{
MemoryRole
}
from
'../../types'
import
type
{
QuestionClassifierNodeType
}
from
'./types'
export
const
mockData
:
QuestionClassifierNodeType
=
{
title
:
'Test'
,
desc
:
'Test'
,
type
:
'Test'
,
query_variable_selector
:
[
'aaa'
,
'name'
],
model
:
{
provider
:
'openai'
,
name
:
'gpt-4'
,
mode
:
'chat'
,
completion_params
:
{
temperature
:
0.7
,
},
},
topics
:
[
{
id
:
'1'
,
name
:
'topic 1'
,
topic
:
'xxxxx'
,
},
{
id
:
'2'
,
name
:
'topic 2'
,
topic
:
'xxxxx2'
,
},
],
instruction
:
'You are an entity extraction model that accepts an input'
,
memory
:
{
role_prefix
:
MemoryRole
.
assistant
,
window
:
{
enabled
:
false
,
size
:
0
,
},
},
}
web/app/components/workflow/nodes/question-classifier/node.tsx
View file @
c441a848
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
InfoPanel
from
'../_base/components/info-panel'
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
Node
:
FC
=
()
=>
{
const
{
provider
,
name
:
modelId
}
=
mockData
.
model
const
topics
=
mockData
.
topics
const
{
textGenerationModelList
,
}
=
useTextGenerationCurrentProviderAndModelAndModelList
()
return
(
return
(
<
div
>
question-classifier
</
div
>
<
div
className=
'px-3'
>
<
ModelSelector
defaultModel=
{
(
provider
||
modelId
)
?
{
provider
,
model
:
modelId
}
:
undefined
}
modelList=
{
textGenerationModelList
}
readonly
/>
<
div
className=
'mt-2 space-y-0.5'
>
{
topics
.
map
(
topic
=>
(
<
InfoPanel
key=
{
topic
.
id
}
title=
{
topic
.
name
}
content=
{
topic
.
topic
}
/>
))
}
</
div
>
</
div
>
)
)
}
}
...
...
web/app/components/workflow/nodes/question-classifier/types.ts
0 → 100644
View file @
c441a848
import
type
{
CommonNodeType
,
Memory
,
ModelConfig
,
ValueSelector
}
from
'@/app/components/workflow/types'
type
Topic
=
{
id
:
string
name
:
string
topic
:
string
}
export
type
QuestionClassifierNodeType
=
CommonNodeType
&
{
query_variable_selector
:
ValueSelector
model
:
ModelConfig
topics
:
Topic
[]
instruction
:
string
memory
:
Memory
}
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