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
df251183
Unverified
Commit
df251183
authored
Jan 31, 2024
by
Yeuoly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support upload image in agent
parent
58ef52b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
16 deletions
+35
-16
index.tsx
...p/configuration/debug/debug-with-multiple-model/index.tsx
+2
-0
chat-input.tsx
web/app/components/base/chat/chat/chat-input.tsx
+5
-2
index.tsx
web/app/components/base/chat/chat/index.tsx
+1
-0
chat-image-uploader.tsx
...pp/components/base/image-uploader/chat-image-uploader.tsx
+27
-14
No files found.
web/app/components/app/configuration/debug/debug-with-multiple-model/index.tsx
View file @
df251183
...
...
@@ -21,6 +21,7 @@ const DebugWithMultipleModel = () => {
mode
,
speechToTextConfig
,
visionConfig
,
isAgent
,
}
=
useDebugConfigurationContext
()
const
{
multipleModelConfigs
,
...
...
@@ -127,6 +128,7 @@ const DebugWithMultipleModel = () => {
onSend=
{
handleSend
}
speechToTextConfig=
{
speechToTextConfig
}
visionConfig=
{
visionConfig
}
isAgent=
{
isAgent
}
/>
</
div
>
)
...
...
web/app/components/base/chat/chat/chat-input.tsx
View file @
df251183
...
...
@@ -32,11 +32,13 @@ import {
type
ChatInputProps
=
{
visionConfig
?:
VisionConfig
speechToTextConfig
?:
EnableType
isAgent
?:
boolean
onSend
?:
OnSend
}
const
ChatInput
:
FC
<
ChatInputProps
>
=
({
visionConfig
,
speechToTextConfig
,
isAgent
,
onSend
,
})
=>
{
const
{
t
}
=
useTranslation
()
...
...
@@ -128,13 +130,14 @@ const ChatInput: FC<ChatInputProps> = ({
`
}
>
{
visionConfig
?.
enabled
&&
(
(
isAgent
||
visionConfig
?.
enabled
)
&&
(
<>
<
div
className=
'absolute bottom-2 left-2 flex items-center'
>
<
ChatImageUploader
isAgent=
{
isAgent
}
settings=
{
visionConfig
}
onUpload=
{
onUpload
}
disabled=
{
files
.
length
>=
visionConfig
.
number_limits
}
disabled=
{
visionConfig
&&
files
.
length
>=
visionConfig
?
.
number_limits
}
/>
<
div
className=
'mx-1 w-[1px] h-4 bg-black/5'
/>
</
div
>
...
...
web/app/components/base/chat/chat/index.tsx
View file @
df251183
...
...
@@ -166,6 +166,7 @@ const Chat: FC<ChatProps> = ({
{
!
noChatInput
&&
(
<
ChatInput
isAgent=
{
config
?.
agent_mode
.
enabled
}
visionConfig=
{
config
?.
file_upload
?.
image
}
speechToTextConfig=
{
config
?.
speech_to_text
}
onSend=
{
onSend
}
...
...
web/app/components/base/image-uploader/chat-image-uploader.tsx
View file @
df251183
...
...
@@ -116,35 +116,48 @@ const UploaderButton: FC<UploaderButtonProps> = ({
}
type
ChatImageUploaderProps
=
{
settings
:
VisionSettings
settings
?
:
VisionSettings
onUpload
:
(
imageFile
:
ImageFile
)
=>
void
disabled
?:
boolean
isAgent
?:
boolean
}
const
ChatImageUploader
:
FC
<
ChatImageUploaderProps
>
=
({
settings
,
onUpload
,
disabled
,
isAgent
,
})
=>
{
const
onlyUploadLocal
=
settings
.
transfer_methods
.
length
===
1
&&
settings
.
transfer_methods
[
0
]
===
TransferMethod
.
local_file
if
(
onlyUploadLocal
)
{
if
(
settings
)
{
const
onlyUploadLocal
=
settings
.
transfer_methods
.
length
===
1
&&
settings
.
transfer_methods
[
0
]
===
TransferMethod
.
local_file
if
(
onlyUploadLocal
)
{
return
(
<
UploadOnlyFromLocal
onUpload=
{
onUpload
}
disabled=
{
disabled
}
limit=
{
+
settings
.
image_file_size_limit
!
}
/>
)
}
return
(
<
UploadOnlyFromLocal
<
UploaderButton
methods=
{
settings
.
transfer_methods
}
onUpload=
{
onUpload
}
disabled=
{
disabled
}
limit=
{
+
settings
.
image_file_size_limit
!
}
/>
)
}
return
(
<
UploaderButton
methods=
{
settings
.
transfer_methods
}
onUpload=
{
onUpload
}
disabled=
{
disabled
}
limit=
{
+
settings
.
image_file_size_limit
!
}
/>
)
else
if
(
isAgent
)
{
return
(
<
UploadOnlyFromLocal
onUpload=
{
onUpload
}
disabled=
{
disabled
}
/>
)
}
else
{
return
<
div
>
123123
</
div
>
}
}
export
default
ChatImageUploader
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