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
9fd55157
Unverified
Commit
9fd55157
authored
Jan 26, 2024
by
zxhlyh
Committed by
GitHub
Jan 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: vision config (#2235)
parent
6c384dba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
28 deletions
+26
-28
index.tsx
web/app/components/app/configuration/debug/index.tsx
+2
-2
index.tsx
web/app/components/app/configuration/index.tsx
+21
-18
index.tsx
...tting/model-provider-page/model-parameter-modal/index.tsx
+3
-8
No files found.
web/app/components/app/configuration/debug/index.tsx
View file @
9fd55157
...
@@ -673,7 +673,7 @@ const Debug: FC<IDebug> = ({
...
@@ -673,7 +673,7 @@ const Debug: FC<IDebug> = ({
}
}
const
handleVisionConfigInMultipleModel
=
()
=>
{
const
handleVisionConfigInMultipleModel
=
()
=>
{
if
(
debugWithMultipleModel
&&
!
visionConfig
.
enabled
)
{
if
(
debugWithMultipleModel
&&
mode
)
{
const
supportedVision
=
multipleModelConfigs
.
some
((
modelConfig
)
=>
{
const
supportedVision
=
multipleModelConfigs
.
some
((
modelConfig
)
=>
{
const
currentProvider
=
textGenerationModelList
.
find
(
modelItem
=>
modelItem
.
provider
===
modelConfig
.
provider
)
const
currentProvider
=
textGenerationModelList
.
find
(
modelItem
=>
modelItem
.
provider
===
modelConfig
.
provider
)
const
currentModel
=
currentProvider
?.
models
.
find
(
model
=>
model
.
model
===
modelConfig
.
model
)
const
currentModel
=
currentProvider
?.
models
.
find
(
model
=>
model
.
model
===
modelConfig
.
model
)
...
@@ -698,7 +698,7 @@ const Debug: FC<IDebug> = ({
...
@@ -698,7 +698,7 @@ const Debug: FC<IDebug> = ({
useEffect
(()
=>
{
useEffect
(()
=>
{
handleVisionConfigInMultipleModel
()
handleVisionConfigInMultipleModel
()
},
[
multipleModelConfigs
])
},
[
multipleModelConfigs
,
mode
])
const
allToolIcons
=
(()
=>
{
const
allToolIcons
=
(()
=>
{
const
icons
:
Record
<
string
,
any
>
=
{}
const
icons
:
Record
<
string
,
any
>
=
{}
modelConfig
.
agentConfig
.
tools
?.
forEach
((
item
:
any
)
=>
{
modelConfig
.
agentConfig
.
tools
?.
forEach
((
item
:
any
)
=>
{
...
...
web/app/components/app/configuration/index.tsx
View file @
9fd55157
...
@@ -284,6 +284,23 @@ const Configuration: FC = () => {
...
@@ -284,6 +284,23 @@ const Configuration: FC = () => {
doSetPromptMode
(
mode
)
doSetPromptMode
(
mode
)
}
}
const
[
visionConfig
,
doSetVisionConfig
]
=
useState
({
enabled
:
false
,
number_limits
:
2
,
detail
:
Resolution
.
low
,
transfer_methods
:
[
TransferMethod
.
local_file
],
})
const
handleSetVisionConfig
=
(
config
:
VisionSettings
,
notNoticeFormattingChanged
?:
boolean
)
=>
{
doSetVisionConfig
({
enabled
:
config
.
enabled
||
false
,
number_limits
:
config
.
number_limits
||
2
,
detail
:
config
.
detail
||
Resolution
.
low
,
transfer_methods
:
config
.
transfer_methods
||
[
TransferMethod
.
local_file
],
})
if
(
!
notNoticeFormattingChanged
)
setFormattingChanged
(
true
)
}
const
{
const
{
chatPromptConfig
,
chatPromptConfig
,
...
@@ -309,7 +326,6 @@ const Configuration: FC = () => {
...
@@ -309,7 +326,6 @@ const Configuration: FC = () => {
setCompletionParams
,
setCompletionParams
,
setStop
:
setTempStop
,
setStop
:
setTempStop
,
})
})
const
setModel
=
async
({
const
setModel
=
async
({
modelId
,
modelId
,
provider
,
provider
,
...
@@ -342,9 +358,8 @@ const Configuration: FC = () => {
...
@@ -342,9 +358,8 @@ const Configuration: FC = () => {
setModelConfig
(
newModelConfig
)
setModelConfig
(
newModelConfig
)
const
supportVision
=
features
&&
features
.
includes
(
ModelFeatureEnum
.
vision
)
const
supportVision
=
features
&&
features
.
includes
(
ModelFeatureEnum
.
vision
)
// eslint-disable-next-line @typescript-eslint/no-use-before-define
setVisionConfig
({
handleSetVisionConfig
({
// eslint-disable-next-line @typescript-eslint/no-use-before-define
...
visionConfig
,
...
visionConfig
,
enabled
:
supportVision
,
enabled
:
supportVision
,
},
true
)
},
true
)
...
@@ -352,18 +367,6 @@ const Configuration: FC = () => {
...
@@ -352,18 +367,6 @@ const Configuration: FC = () => {
}
}
const
isShowVisionConfig
=
!!
currModel
?.
features
?.
includes
(
ModelFeatureEnum
.
vision
)
const
isShowVisionConfig
=
!!
currModel
?.
features
?.
includes
(
ModelFeatureEnum
.
vision
)
const
[
visionConfig
,
doSetVisionConfig
]
=
useState
({
enabled
:
false
,
number_limits
:
2
,
detail
:
Resolution
.
low
,
transfer_methods
:
[
TransferMethod
.
local_file
],
})
const
setVisionConfig
=
(
config
:
VisionSettings
,
notNoticeFormattingChanged
?:
boolean
)
=>
{
doSetVisionConfig
(
config
)
if
(
!
notNoticeFormattingChanged
)
setFormattingChanged
(
true
)
}
useEffect
(()
=>
{
useEffect
(()
=>
{
(
async
()
=>
{
(
async
()
=>
{
...
@@ -484,7 +487,7 @@ const Configuration: FC = () => {
...
@@ -484,7 +487,7 @@ const Configuration: FC = () => {
}
}
if
(
modelConfig
.
file_upload
)
if
(
modelConfig
.
file_upload
)
s
etVisionConfig
(
modelConfig
.
file_upload
.
image
,
true
)
handleS
etVisionConfig
(
modelConfig
.
file_upload
.
image
,
true
)
syncToPublishedConfig
(
config
)
syncToPublishedConfig
(
config
)
setPublishedConfig
(
config
)
setPublishedConfig
(
config
)
...
@@ -727,7 +730,7 @@ const Configuration: FC = () => {
...
@@ -727,7 +730,7 @@ const Configuration: FC = () => {
hasSetContextVar
,
hasSetContextVar
,
isShowVisionConfig
,
isShowVisionConfig
,
visionConfig
,
visionConfig
,
setVisionConfig
,
setVisionConfig
:
handleSetVisionConfig
,
}
}
}
}
>
>
<>
<>
...
...
web/app/components/header/account-setting/model-provider-page/model-parameter-modal/index.tsx
View file @
9fd55157
...
@@ -26,7 +26,6 @@ import {
...
@@ -26,7 +26,6 @@ import {
PortalToFollowElemContent
,
PortalToFollowElemContent
,
PortalToFollowElemTrigger
,
PortalToFollowElemTrigger
,
}
from
'@/app/components/base/portal-to-follow-elem'
}
from
'@/app/components/base/portal-to-follow-elem'
import
{
CubeOutline
}
from
'@/app/components/base/icons/src/vender/line/shapes'
import
{
fetchModelParameterRules
}
from
'@/service/common'
import
{
fetchModelParameterRules
}
from
'@/service/common'
import
Loading
from
'@/app/components/base/loading'
import
Loading
from
'@/app/components/base/loading'
import
{
useProviderContext
}
from
'@/context/provider-context'
import
{
useProviderContext
}
from
'@/context/provider-context'
...
@@ -198,14 +197,10 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
...
@@ -198,14 +197,10 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
</
PortalToFollowElemTrigger
>
</
PortalToFollowElemTrigger
>
<
PortalToFollowElemContent
className=
'z-[60]'
>
<
PortalToFollowElemContent
className=
'z-[60]'
>
<
div
className=
'w-[496px] rounded-xl border border-gray-100 bg-white shadow-xl'
>
<
div
className=
'w-[496px] rounded-xl border border-gray-100 bg-white shadow-xl'
>
<
div
className=
'flex items-center px-4 h-12 rounded-t-xl border-b border-gray-100 bg-gray-50 text-md font-medium text-gray-900'
>
<
div
className=
'max-h-[480px] px-10 pt-6 pb-8 overflow-y-auto'
>
<
CubeOutline
className=
'mr-2 w-4 h-4 text-primary-600'
/>
{
t
(
'common.modelProvider.modelAndParameters'
)
}
</
div
>
<
div
className=
'max-h-[480px] px-10 pt-4 pb-8 overflow-y-auto'
>
<
div
className=
'flex items-center justify-between h-8'
>
<
div
className=
'flex items-center justify-between h-8'
>
<
div
className=
'
text-sm font-medium
text-gray-900'
>
<
div
className=
'
font-semibold
text-gray-900'
>
{
t
(
'common.modelProvider.model'
)
}
{
t
(
'common.modelProvider.model'
)
.
toLocaleUpperCase
()
}
</
div
>
</
div
>
<
ModelSelector
<
ModelSelector
defaultModel=
{
(
provider
||
modelId
)
?
{
provider
,
model
:
modelId
}
:
undefined
}
defaultModel=
{
(
provider
||
modelId
)
?
{
provider
,
model
:
modelId
}
:
undefined
}
...
...
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