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
c3f99779
Commit
c3f99779
authored
Mar 01, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: vision config
parent
0518da1e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
8 deletions
+99
-8
field.tsx
web/app/components/workflow/nodes/_base/components/field.tsx
+4
-1
resolution-picker.tsx
...nents/workflow/nodes/llm/components/resolution-picker.tsx
+65
-0
mock.ts
web/app/components/workflow/nodes/llm/mock.ts
+1
-2
panel.tsx
web/app/components/workflow/nodes/llm/panel.tsx
+10
-4
types.ts
web/app/components/workflow/nodes/llm/types.ts
+0
-1
use-config.ts
web/app/components/workflow/nodes/llm/use-config.ts
+9
-0
workflow.ts
web/i18n/en-US/workflow.ts
+5
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+5
-0
No files found.
web/app/components/workflow/nodes/_base/components/field.tsx
View file @
c3f99779
...
@@ -33,7 +33,10 @@ const Filed: FC<Props> = ({
...
@@ -33,7 +33,10 @@ const Filed: FC<Props> = ({
<
div
className=
'flex items-center h-6'
>
<
div
className=
'flex items-center h-6'
>
<
div
className=
'text-xs font-medium text-gray-700 uppercase'
>
{
title
}
</
div
>
<
div
className=
'text-xs font-medium text-gray-700 uppercase'
>
{
title
}
</
div
>
{
tooltip
&&
(
{
tooltip
&&
(
<
TooltipPlus
popupContent=
{
tooltip
}
>
<
TooltipPlus
popupContent=
{
<
div
className=
'w-[120px]'
>
{
tooltip
}
</
div
>
}
>
<
HelpCircle
className=
'w-3.5 h-3.5 ml-0.5 text-gray-400'
/>
<
HelpCircle
className=
'w-3.5 h-3.5 ml-0.5 text-gray-400'
/>
</
TooltipPlus
>
</
TooltipPlus
>
)
}
)
}
...
...
web/app/components/workflow/nodes/llm/components/resolution-picker.tsx
0 → 100644
View file @
c3f99779
'use client'
import
type
{
FC
}
from
'react'
import
React
,
{
useCallback
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
cn
from
'classnames'
import
{
Resolution
}
from
'@/types/app'
const
i18nPrefix
=
'workflow.nodes.llm'
type
ItemProps
=
{
title
:
string
value
:
Resolution
onSelect
:
(
value
:
Resolution
)
=>
void
isSelected
:
boolean
}
const
Item
:
FC
<
ItemProps
>
=
({
title
,
value
,
onSelect
,
isSelected
})
=>
{
const
handleSelect
=
useCallback
(()
=>
{
if
(
isSelected
)
return
onSelect
(
value
)
},
[
value
,
onSelect
,
isSelected
])
return
(
<
div
className=
{
cn
(
isSelected
?
'bg-white border-[2px] border-primary-400 shadow-xs'
:
'bg-gray-25 border border-gray-100'
,
'flex items-center h-8 px-3 rounded-xl text-[13px] font-normal text-gray-900 cursor-pointer'
)
}
onClick=
{
handleSelect
}
>
{
title
}
</
div
>
)
}
type
Props
=
{
value
:
Resolution
onChange
:
(
value
:
Resolution
)
=>
void
}
const
ResolutionPicker
:
FC
<
Props
>
=
({
value
,
onChange
,
})
=>
{
const
{
t
}
=
useTranslation
()
return
(
<
div
className=
'flex items-center'
>
<
div
className=
'mr-2 text-xs font-medium text-gray-500 uppercase'
>
{
t
(
`${i18nPrefix}.resolution.name`
)
}
</
div
>
<
div
className=
'flex items-center space-x-1'
>
<
Item
title=
{
t
(
`${i18nPrefix}.resolution.high`
)
}
value=
{
Resolution
.
high
}
onSelect=
{
onChange
}
isSelected=
{
value
===
Resolution
.
high
}
/>
<
Item
title=
{
t
(
`${i18nPrefix}.resolution.low`
)
}
value=
{
Resolution
.
low
}
onSelect=
{
onChange
}
isSelected=
{
value
===
Resolution
.
low
}
/>
</
div
>
</
div
>
)
}
export
default
React
.
memo
(
ResolutionPicker
)
web/app/components/workflow/nodes/llm/mock.ts
View file @
c3f99779
...
@@ -40,8 +40,7 @@ export const mockData: LLMNodeType = {
...
@@ -40,8 +40,7 @@ export const mockData: LLMNodeType = {
variable_selector
:
[
'aaa'
,
'name'
],
variable_selector
:
[
'aaa'
,
'name'
],
},
},
vision
:
{
vision
:
{
enabled
:
false
,
enabled
:
true
,
variable_selector
:
[],
configs
:
{
configs
:
{
detail
:
Resolution
.
low
,
detail
:
Resolution
.
low
,
},
},
...
...
web/app/components/workflow/nodes/llm/panel.tsx
View file @
c3f99779
...
@@ -4,6 +4,7 @@ import MemoryConfig from '../_base/components/memory-config'
...
@@ -4,6 +4,7 @@ import MemoryConfig from '../_base/components/memory-config'
import
VarReferencePicker
from
'../_base/components/variable/var-reference-picker'
import
VarReferencePicker
from
'../_base/components/variable/var-reference-picker'
import
useConfig
from
'./use-config'
import
useConfig
from
'./use-config'
import
{
mockData
}
from
'./mock'
import
{
mockData
}
from
'./mock'
import
ResolutionPicker
from
'./components/resolution-picker'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
import
VarList
from
'@/app/components/workflow/nodes/_base/components/variable/var-list'
import
Field
from
'@/app/components/workflow/nodes/_base/components/field'
import
Field
from
'@/app/components/workflow/nodes/_base/components/field'
import
AddButton
from
'@/app/components/base/button/add-button'
import
AddButton
from
'@/app/components/base/button/add-button'
...
@@ -25,6 +26,7 @@ const Panel: FC = () => {
...
@@ -25,6 +26,7 @@ const Panel: FC = () => {
handleAddVariable
,
handleAddVariable
,
handleContextVarChange
,
handleContextVarChange
,
handleMemoryChange
,
handleMemoryChange
,
handleVisionResolutionChange
,
}
=
useConfig
(
mockData
)
}
=
useConfig
(
mockData
)
const
isChatApp
=
true
// TODO: get from app context
const
isChatApp
=
true
// TODO: get from app context
const
model
=
inputs
.
model
const
model
=
inputs
.
model
...
@@ -106,10 +108,14 @@ const Panel: FC = () => {
...
@@ -106,10 +108,14 @@ const Panel: FC = () => {
{
/* Vision: GPT4-vision and so on */
}
{
/* Vision: GPT4-vision and so on */
}
<
Field
<
Field
title=
{
t
(
`${i18nPrefix}.vision`
)
}
title=
{
t
(
`${i18nPrefix}.vision`
)
}
inline
tooltip=
{
t
(
'appDebug.vision.description'
)
!
}
>
operations=
{
Vision
<
ResolutionPicker
</
Field
>
value=
{
inputs
.
vision
.
configs
.
detail
}
onChange=
{
handleVisionResolutionChange
}
/>
}
/>
</
div
>
</
div
>
<
Split
/>
<
Split
/>
<
div
className=
'px-4 pt-4 pb-2'
>
<
div
className=
'px-4 pt-4 pb-2'
>
...
...
web/app/components/workflow/nodes/llm/types.ts
View file @
c3f99779
...
@@ -12,7 +12,6 @@ export type LLMNodeType = CommonNodeType & {
...
@@ -12,7 +12,6 @@ export type LLMNodeType = CommonNodeType & {
}
}
vision
:
{
vision
:
{
enabled
:
boolean
enabled
:
boolean
variable_selector
:
ValueSelector
configs
:
{
configs
:
{
detail
:
Resolution
detail
:
Resolution
}
}
...
...
web/app/components/workflow/nodes/llm/use-config.ts
View file @
c3f99779
...
@@ -3,6 +3,7 @@ import produce from 'immer'
...
@@ -3,6 +3,7 @@ import produce from 'immer'
import
useVarList
from
'../_base/hooks/use-var-list'
import
useVarList
from
'../_base/hooks/use-var-list'
import
type
{
Memory
,
ValueSelector
}
from
'../../types'
import
type
{
Memory
,
ValueSelector
}
from
'../../types'
import
type
{
LLMNodeType
}
from
'./types'
import
type
{
LLMNodeType
}
from
'./types'
import
type
{
Resolution
}
from
'@/types/app'
const
useConfig
=
(
initInputs
:
LLMNodeType
)
=>
{
const
useConfig
=
(
initInputs
:
LLMNodeType
)
=>
{
const
[
inputs
,
setInputs
]
=
useState
<
LLMNodeType
>
(
initInputs
)
const
[
inputs
,
setInputs
]
=
useState
<
LLMNodeType
>
(
initInputs
)
...
@@ -45,6 +46,13 @@ const useConfig = (initInputs: LLMNodeType) => {
...
@@ -45,6 +46,13 @@ const useConfig = (initInputs: LLMNodeType) => {
setInputs
(
newInputs
)
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
},
[
inputs
,
setInputs
])
const
handleVisionResolutionChange
=
useCallback
((
newResolution
:
Resolution
)
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
draft
.
vision
.
configs
.
detail
=
newResolution
})
setInputs
(
newInputs
)
},
[
inputs
,
setInputs
])
return
{
return
{
inputs
,
inputs
,
handleModelChanged
,
handleModelChanged
,
...
@@ -53,6 +61,7 @@ const useConfig = (initInputs: LLMNodeType) => {
...
@@ -53,6 +61,7 @@ const useConfig = (initInputs: LLMNodeType) => {
handleAddVariable
,
handleAddVariable
,
handleContextVarChange
,
handleContextVarChange
,
handleMemoryChange
,
handleMemoryChange
,
handleVisionResolutionChange
,
}
}
}
}
...
...
web/i18n/en-US/workflow.ts
View file @
c3f99779
...
@@ -50,6 +50,11 @@ const translation = {
...
@@ -50,6 +50,11 @@ const translation = {
contextTooltip
:
'You can import Knowledge as context'
,
contextTooltip
:
'You can import Knowledge as context'
,
prompt
:
'prompt'
,
prompt
:
'prompt'
,
vision
:
'vision'
,
vision
:
'vision'
,
resolution
:
{
name
:
'Resolution'
,
high
:
'High'
,
low
:
'Low'
,
},
outputVars
:
{
outputVars
:
{
output
:
'Generate content'
,
output
:
'Generate content'
,
usage
:
'Model Usage Information'
,
usage
:
'Model Usage Information'
,
...
...
web/i18n/zh-Hans/workflow.ts
View file @
c3f99779
...
@@ -50,6 +50,11 @@ const translation = {
...
@@ -50,6 +50,11 @@ const translation = {
contextTooltip
:
'您可以导入知识库作为上下文'
,
contextTooltip
:
'您可以导入知识库作为上下文'
,
prompt
:
'提示词'
,
prompt
:
'提示词'
,
vision
:
'视觉'
,
vision
:
'视觉'
,
resolution
:
{
name
:
'分辨率'
,
high
:
'高'
,
low
:
'低'
,
},
outputVars
:
{
outputVars
:
{
output
:
'生成内容'
,
output
:
'生成内容'
,
usage
:
'模型用量信息'
,
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