Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
6c77134e
authored
Nov 28, 2024
by
Archer
Committed by
GitHub
Nov 28, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix plugin runtime cannot upload files (#3271)
* app logo * fix: plugin runtime cannot upload file
parent
93e302b7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
15 deletions
+27
-15
projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx
+4
-1
projects/app/src/components/core/chat/ChatContainer/ChatBox/hooks/useFileUpload.tsx
+6
-7
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx
+6
-2
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx
+8
-2
projects/app/src/pages/app/list/components/CreateModal.tsx
+3
-3
No files found.
projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx
View file @
6c77134e
...
...
@@ -76,7 +76,10 @@ const ChatInput = ({
hasFileUploading
}
=
useFileUpload
({
fileSelectConfig
,
fileCtrl
fileCtrl
,
outLinkAuthData
,
appId
,
chatId
});
const
havInput
=
!!
inputValue
||
fileList
.
length
>
0
;
const
canSendMessage
=
havInput
&&
!
hasFileUploading
;
...
...
projects/app/src/components/core/chat/ChatContainer/ChatBox/hooks/useFileUpload.tsx
View file @
6c77134e
...
...
@@ -14,24 +14,23 @@ import { ChatBoxInputFormType, UserInputFileItemType } from '../type';
import
{
AppFileSelectConfigType
}
from
'@fastgpt/global/core/app/type'
;
import
{
documentFileType
}
from
'@fastgpt/global/common/file/constants'
;
import
{
useSystemStore
}
from
'@/web/common/system/useSystemStore'
;
import
{
useContextSelector
}
from
'use-context-selector'
;
import
{
ChatBoxContext
}
from
'../Provider'
;
import
{
OutLinkChatAuthProps
}
from
'@fastgpt/global/support/permission/chat'
;
type
UseFileUploadOptions
=
{
fileSelectConfig
:
AppFileSelectConfigType
;
fileCtrl
:
UseFieldArrayReturn
<
ChatBoxInputFormType
,
'files'
,
'id'
>
;
outLinkAuthData
?:
OutLinkChatAuthProps
;
appId
:
string
;
chatId
:
string
;
};
export
const
useFileUpload
=
(
props
:
UseFileUploadOptions
)
=>
{
const
{
fileSelectConfig
,
fileCtrl
}
=
props
;
const
{
fileSelectConfig
,
fileCtrl
,
outLinkAuthData
,
appId
,
chatId
}
=
props
;
const
{
toast
}
=
useToast
();
const
{
t
}
=
useTranslation
();
const
{
feConfigs
}
=
useSystemStore
();
const
outLinkAuthData
=
useContextSelector
(
ChatBoxContext
,
(
v
)
=>
v
.
outLinkAuthData
);
const
appId
=
useContextSelector
(
ChatBoxContext
,
(
v
)
=>
v
.
appId
);
const
chatId
=
useContextSelector
(
ChatBoxContext
,
(
v
)
=>
v
.
chatId
);
const
{
update
:
updateFiles
,
remove
:
removeFiles
,
...
...
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx
View file @
6c77134e
...
...
@@ -33,6 +33,7 @@ const RenderInput = () => {
const
isChatting
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
isChatting
);
const
fileSelectConfig
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
fileSelectConfig
);
const
instruction
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
instruction
);
const
appId
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
appId
);
const
chatId
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
chatId
);
const
outLinkAuthData
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
outLinkAuthData
);
...
...
@@ -61,14 +62,17 @@ const RenderInput = () => {
hasFileUploading
}
=
useFileUpload
({
fileSelectConfig
,
fileCtrl
fileCtrl
,
outLinkAuthData
,
appId
,
chatId
});
const
isDisabledInput
=
histories
.
length
>
0
;
useRequest2
(
uploadFiles
,
{
manual
:
false
,
errorToast
:
t
(
'common:upload_file_error'
),
refreshDeps
:
[
fileList
,
outLinkAuthData
,
chatId
]
refreshDeps
:
[
fileList
,
outLinkAuthData
]
});
/* Global files(abandon) <=== */
...
...
projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx
View file @
6c77134e
...
...
@@ -19,6 +19,7 @@ import MyNumberInput from '@fastgpt/web/components/common/Input/NumberInput';
import
{
isEqual
}
from
'lodash'
;
import
{
ChatItemContext
}
from
'@/web/core/chat/context/chatItemContext'
;
import
{
ChatRecordContext
}
from
'@/web/core/chat/context/chatRecordContext'
;
import
{
PluginRunContext
}
from
'../context'
;
const
JsonEditor
=
dynamic
(()
=>
import
(
'@fastgpt/web/components/common/Textarea/JsonEditor'
));
...
...
@@ -37,6 +38,9 @@ const FileSelector = ({
const
variablesForm
=
useContextSelector
(
ChatItemContext
,
(
v
)
=>
v
.
variablesForm
);
const
histories
=
useContextSelector
(
ChatRecordContext
,
(
v
)
=>
v
.
chatRecords
);
const
appId
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
appId
);
const
chatId
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
chatId
);
const
outLinkAuthData
=
useContextSelector
(
PluginRunContext
,
(
v
)
=>
v
.
outLinkAuthData
);
const
fileCtrl
=
useFieldArray
({
control
:
variablesForm
.
control
,
...
...
@@ -58,8 +62,10 @@ const FileSelector = ({
canSelectImg
:
input
.
canSelectImg
??
false
,
maxFiles
:
input
.
maxFiles
??
5
},
// @ts-ignore
fileCtrl
outLinkAuthData
,
appId
,
chatId
,
fileCtrl
:
fileCtrl
as
any
});
useEffect
(()
=>
{
...
...
projects/app/src/pages/app/list/components/CreateModal.tsx
View file @
6c77134e
...
...
@@ -53,18 +53,18 @@ const CreateModal = ({
[
AppTypeEnum
.
simple
]:
{
icon
:
'core/app/simpleBot'
,
title
:
t
(
'app:type.Create simple bot'
),
avatar
:
'
/imgs/app/avatar/simple.svg
'
,
avatar
:
'
core/app/type/simpleFill
'
,
emptyCreateText
:
t
(
'app:create_empty_app'
)
},
[
AppTypeEnum
.
workflow
]:
{
icon
:
'core/app/type/workflowFill'
,
avatar
:
'
/imgs/app/avatar/workflow.svg
'
,
avatar
:
'
core/app/type/workflowFill
'
,
title
:
t
(
'app:type.Create workflow bot'
),
emptyCreateText
:
t
(
'app:create_empty_workflow'
)
},
[
AppTypeEnum
.
plugin
]:
{
icon
:
'core/app/type/pluginFill'
,
avatar
:
'
/imgs/app/avatar/plugin.svg
'
,
avatar
:
'
core/app/type/pluginFill
'
,
title
:
t
(
'app:type.Create plugin bot'
),
emptyCreateText
:
t
(
'app:create_empty_plugin'
)
}
...
...
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