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
6f6f0322
Commit
6f6f0322
authored
Mar 01, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: choose context var
parent
0acb2db9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
21 deletions
+21
-21
page.tsx
web/app/(commonLayout)/workflow/nodes/page.tsx
+1
-1
mock.ts
web/app/components/workflow/nodes/llm/mock.ts
+1
-1
panel.tsx
web/app/components/workflow/nodes/llm/panel.tsx
+11
-14
types.ts
web/app/components/workflow/nodes/llm/types.ts
+1
-1
use-config.ts
web/app/components/workflow/nodes/llm/use-config.ts
+4
-4
workflow.ts
web/i18n/en-US/workflow.ts
+1
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+2
-0
No files found.
web/app/(commonLayout)/workflow/nodes/page.tsx
View file @
6f6f0322
...
...
@@ -6,7 +6,7 @@ import Workflow from '@/app/components/workflow'
import
{
BlockEnum
}
from
'@/app/components/workflow/types'
const
nodes
=
[
BlockEnum
.
KnowledgeRetrieval
/* 4 */
,
BlockEnum
.
Start
/* 1 */
,
BlockEnum
.
DirectAnswer
/* 2 */
,
BlockEnum
.
LLM
/* 3
*/
,
BlockEnum
.
QuestionClassifier
/* 5 */
,
BlockEnum
.
LLM
/* 3 */
,
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
.
Tool
/* 10 */
,
BlockEnum
.
VariableAssigner
/* 11 */
,
BlockEnum
.
End
/* 12 */
,
].
map
((
item
,
i
)
=>
({
...
...
web/app/components/workflow/nodes/llm/mock.ts
View file @
6f6f0322
...
...
@@ -34,7 +34,7 @@ export const mockData: LLMNodeType = {
},
context
:
{
enabled
:
false
,
size
:
0
,
variable_selector
:
[
'aaa'
,
'name'
]
,
},
vision
:
{
enabled
:
false
,
...
...
web/app/components/workflow/nodes/llm/panel.tsx
View file @
6f6f0322
import
type
{
FC
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
MemoryConfig
from
'../_base/components/memory-config'
import
VarReferencePicker
from
'../_base/components/variable/var-reference-picker'
import
useConfig
from
'./use-config'
import
{
mockData
}
from
'./mock'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
...
...
@@ -8,7 +9,6 @@ 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'
import
ModelParameterModal
from
'@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
import
Switch
from
'@/app/components/base/switch'
import
OutputVars
,
{
VarItem
}
from
'@/app/components/workflow/nodes/_base/components/output-vars'
const
i18nPrefix
=
'workflow.nodes.llm'
...
...
@@ -23,7 +23,7 @@ const Panel: FC = () => {
handleCompletionParamsChange
,
handleVarListChange
,
handleAddVariable
,
toggleContextEnabled
,
handleContextVarChange
,
handleMemoryChange
,
}
=
useConfig
(
mockData
)
const
model
=
inputs
.
model
...
...
@@ -63,21 +63,18 @@ const Panel: FC = () => {
/>
</
Field
>
{
/* knowledge */
}
<
Field
title=
{
t
(
`${i18nPrefix}.context`
)
}
operations=
{
<
Switch
defaultValue=
{
inputs
.
context
.
enabled
}
onChange=
{
toggleContextEnabled
}
size=
'md'
/>
}
tooltip=
{
t
(
`${i18nPrefix}.contextTooltip`
)
!
}
>
{
inputs
.
context
.
enabled
?
(
<
div
>
Context
</
div
>
)
:
null
}
<
VarReferencePicker
readonly=
{
readOnly
}
isShowNodeName
value=
{
inputs
.
context
.
variable_selector
}
onChange=
{
handleContextVarChange
}
/>
</
Field
>
{
/* Prompt */
}
...
...
web/app/components/workflow/nodes/llm/types.ts
View file @
6f6f0322
...
...
@@ -8,7 +8,7 @@ export type LLMNodeType = CommonNodeType & {
memory
:
Memory
context
:
{
enabled
:
boolean
size
:
numbe
r
variable_selector
:
ValueSelecto
r
}
vision
:
{
enabled
:
boolean
...
...
web/app/components/workflow/nodes/llm/use-config.ts
View file @
6f6f0322
import
{
useCallback
,
useState
}
from
'react'
import
produce
from
'immer'
import
useVarList
from
'../_base/hooks/use-var-list'
import
type
{
Memory
}
from
'../../types'
import
type
{
Memory
,
ValueSelector
}
from
'../../types'
import
type
{
LLMNodeType
}
from
'./types'
const
useConfig
=
(
initInputs
:
LLMNodeType
)
=>
{
...
...
@@ -31,9 +31,9 @@ const useConfig = (initInputs: LLMNodeType) => {
})
// context
const
toggleContextEnabled
=
useCallback
((
)
=>
{
const
handleContextVarChange
=
useCallback
((
newVar
:
ValueSelector
)
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
draft
.
context
.
enabled
=
!
draft
.
context
.
enabled
draft
.
context
.
variable_selector
=
newVar
})
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
...
...
@@ -51,7 +51,7 @@ const useConfig = (initInputs: LLMNodeType) => {
handleCompletionParamsChange
,
handleVarListChange
,
handleAddVariable
,
toggleContextEnabled
,
handleContextVarChange
,
handleMemoryChange
,
}
}
...
...
web/i18n/en-US/workflow.ts
View file @
6f6f0322
...
...
@@ -47,6 +47,7 @@ const translation = {
model
:
'model'
,
variables
:
'variables'
,
context
:
'context'
,
contextTooltip
:
'You can import Knowledge as context'
,
prompt
:
'prompt'
,
vision
:
'vision'
,
outputVars
:
{
...
...
web/i18n/zh-Hans/workflow.ts
View file @
6f6f0322
...
...
@@ -14,6 +14,7 @@ const translation = {
},
start
:
{
required
:
'必填'
,
inputField
:
'输入字段'
,
builtInVar
:
'内置变量'
,
outputVars
:
{
query
:
'用户输入'
,
...
...
@@ -46,6 +47,7 @@ const translation = {
model
:
'模型'
,
variables
:
'变量'
,
context
:
'上下文'
,
contextTooltip
:
'您可以导入知识库作为上下文'
,
prompt
:
'提示词'
,
vision
:
'视觉'
,
outputVars
:
{
...
...
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