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
9c0d44fa
Commit
9c0d44fa
authored
Feb 29, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: llm node support config memroy
parent
f95eb2df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
5 deletions
+32
-5
page.tsx
web/app/(commonLayout)/workflow/nodes/page.tsx
+2
-2
panel.tsx
web/app/components/workflow/nodes/llm/panel.tsx
+21
-3
use-config.ts
web/app/components/workflow/nodes/llm/use-config.ts
+9
-0
No files found.
web/app/(commonLayout)/workflow/nodes/page.tsx
View file @
9c0d44fa
...
@@ -6,8 +6,8 @@ import Workflow from '@/app/components/workflow'
...
@@ -6,8 +6,8 @@ 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
.
QuestionClassifier
/* 5 */
,
BlockEnum
.
Tool
/* 10 */
,
BlockEnum
.
VariableAssigner
/* 11 */
,
BlockEnum
.
Start
/* 1 */
,
BlockEnum
.
DirectAnswer
/* 2 */
,
BlockEnum
.
LLM
/* 3 */
,
BlockEnum
.
KnowledgeRetrieval
/* 4
*/
,
BlockEnum
.
LLM
/* 3 */
,
BlockEnum
.
VariableAssigner
/* 11 */
,
BlockEnum
.
Start
/* 1 */
,
BlockEnum
.
DirectAnswer
/* 2 */
,
BlockEnum
.
KnowledgeRetrieval
/* 4 */
,
BlockEnum
.
QuestionClassifier
/* 5
*/
,
BlockEnum
.
IfElse
/* 6 */
,
BlockEnum
.
Code
/* 7 */
,
BlockEnum
.
TemplateTransform
/* 8 */
,
BlockEnum
.
HttpRequest
/* 9 */
,
BlockEnum
.
IfElse
/* 6 */
,
BlockEnum
.
Code
/* 7 */
,
BlockEnum
.
TemplateTransform
/* 8 */
,
BlockEnum
.
HttpRequest
/* 9 */
,
BlockEnum
.
Tool
/* 10 */
,
BlockEnum
.
End
/* 12 */
,
BlockEnum
.
End
/* 12 */
,
].
map
((
item
,
i
)
=>
({
].
map
((
item
,
i
)
=>
({
id
:
`
${
i
+
1
}
`
,
id
:
`
${
i
+
1
}
`
,
...
...
web/app/components/workflow/nodes/llm/panel.tsx
View file @
9c0d44fa
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
MemoryConfig
from
'../_base/components/memory-config'
import
useConfig
from
'./use-config'
import
useConfig
from
'./use-config'
import
{
mockData
}
from
'./mock'
import
{
mockData
}
from
'./mock'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
...
@@ -23,10 +24,11 @@ const Panel: FC = () => {
...
@@ -23,10 +24,11 @@ const Panel: FC = () => {
handleVarListChange
,
handleVarListChange
,
handleAddVariable
,
handleAddVariable
,
toggleContextEnabled
,
toggleContextEnabled
,
handleMemoryChange
,
}
=
useConfig
(
mockData
)
}
=
useConfig
(
mockData
)
const
model
=
inputs
.
model
const
model
=
inputs
.
model
//
const modelMode = inputs.model?.mode
const
modelMode
=
inputs
.
model
?.
mode
//
const isChatMode = modelMode === 'chat'
const
isChatMode
=
modelMode
===
'chat'
return
(
return
(
<
div
className=
'mt-2'
>
<
div
className=
'mt-2'
>
...
@@ -77,12 +79,28 @@ const Panel: FC = () => {
...
@@ -77,12 +79,28 @@ const Panel: FC = () => {
)
)
:
null
}
:
null
}
</
Field
>
</
Field
>
{
/* Prompt */
}
<
Field
<
Field
title=
{
t
(
`${i18nPrefix}.prompt`
)
}
title=
{
t
(
`${i18nPrefix}.prompt`
)
}
>
>
Prompt
Prompt
</
Field
>
</
Field
>
<
Split
/>
{
/* Memory */
}
{
isChatMode
&&
(
<>
<
MemoryConfig
readonly=
{
readOnly
}
payload=
{
inputs
.
memory
}
onChange=
{
handleMemoryChange
}
canSetRoleName
/>
<
Split
/>
</>
)
}
{
/* Vision: GPT4-vision and so on */
}
<
Field
<
Field
title=
{
t
(
`${i18nPrefix}.vision`
)
}
title=
{
t
(
`${i18nPrefix}.vision`
)
}
inline
inline
...
...
web/app/components/workflow/nodes/llm/use-config.ts
View file @
9c0d44fa
import
{
useCallback
,
useState
}
from
'react'
import
{
useCallback
,
useState
}
from
'react'
import
produce
from
'immer'
import
produce
from
'immer'
import
useVarList
from
'../_base/hooks/use-var-list'
import
useVarList
from
'../_base/hooks/use-var-list'
import
type
{
Memory
}
from
'../../types'
import
type
{
LLMNodeType
}
from
'./types'
import
type
{
LLMNodeType
}
from
'./types'
const
useConfig
=
(
initInputs
:
LLMNodeType
)
=>
{
const
useConfig
=
(
initInputs
:
LLMNodeType
)
=>
{
...
@@ -37,6 +38,13 @@ const useConfig = (initInputs: LLMNodeType) => {
...
@@ -37,6 +38,13 @@ const useConfig = (initInputs: LLMNodeType) => {
setInputs
(
newInputs
)
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
},
[
inputs
,
setInputs
])
const
handleMemoryChange
=
useCallback
((
newMemory
:
Memory
)
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
draft
.
memory
=
newMemory
})
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
return
{
return
{
inputs
,
inputs
,
handleModelChanged
,
handleModelChanged
,
...
@@ -44,6 +52,7 @@ const useConfig = (initInputs: LLMNodeType) => {
...
@@ -44,6 +52,7 @@ const useConfig = (initInputs: LLMNodeType) => {
handleVarListChange
,
handleVarListChange
,
handleAddVariable
,
handleAddVariable
,
toggleContextEnabled
,
toggleContextEnabled
,
handleMemoryChange
,
}
}
}
}
...
...
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