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
f5460683
authored
Jul 17, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app template
parent
ed42bb6c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
59 additions
and
25 deletions
+59
-25
client/public/imgs/module/db.png
+0
-0
client/public/imgs/module/db.png:Zone.Identifier
+3
-0
client/src/components/ChatBox/index.tsx
+4
-6
client/src/components/Select/index.tsx
+8
-5
client/src/constants/app.ts
+0
-0
client/src/constants/flow/ModuleTemplate.ts
+5
-5
client/src/pages/api/admin/initv4.ts
+28
-0
client/src/pages/api/openapi/modules/agent/recognizeIntention.ts
+3
-3
client/src/pages/app/detail/components/Settings.tsx
+2
-2
client/src/pages/app/detail/components/edit/index.tsx
+2
-2
client/src/pages/app/list/component/CreateModal.tsx
+4
-2
No files found.
client/public/imgs/module/db.png
View file @
f5460683
1.44 KB
|
W:
|
H:
1.46 KB
|
W:
|
H:
2-up
Swipe
Onion skin
client/public/imgs/module/db.png:Zone.Identifier
0 → 100644
View file @
f5460683
[ZoneTransfer]
ZoneId=3
HostUrl=about:internet
client/src/components/ChatBox/index.tsx
View file @
f5460683
...
@@ -89,6 +89,7 @@ const ChatBox = (
...
@@ -89,6 +89,7 @@ const ChatBox = (
const
TextareaDom
=
useRef
<
HTMLTextAreaElement
>
(
null
);
const
TextareaDom
=
useRef
<
HTMLTextAreaElement
>
(
null
);
const
controller
=
useRef
(
new
AbortController
());
const
controller
=
useRef
(
new
AbortController
());
const
[
refresh
,
setRefresh
]
=
useState
(
false
);
const
[
variables
,
setVariables
]
=
useState
<
Record
<
string
,
any
>>
({});
const
[
variables
,
setVariables
]
=
useState
<
Record
<
string
,
any
>>
({});
const
[
chatHistory
,
setChatHistory
]
=
useState
<
ChatSiteItemType
[]
>
([]);
const
[
chatHistory
,
setChatHistory
]
=
useState
<
ChatSiteItemType
[]
>
([]);
...
@@ -111,7 +112,7 @@ const ChatBox = (
...
@@ -111,7 +112,7 @@ const ChatBox = (
const
isLargeWidth
=
ChatBoxRef
?.
current
?.
clientWidth
&&
ChatBoxRef
?.
current
?.
clientWidth
>=
900
;
const
isLargeWidth
=
ChatBoxRef
?.
current
?.
clientWidth
&&
ChatBoxRef
?.
current
?.
clientWidth
>=
900
;
const
{
register
,
reset
,
setValue
,
handleSubmit
}
=
useForm
<
Record
<
string
,
any
>>
({
const
{
register
,
reset
,
getValues
,
setValue
,
handleSubmit
}
=
useForm
<
Record
<
string
,
any
>>
({
defaultValues
:
variables
defaultValues
:
variables
});
});
...
@@ -370,12 +371,10 @@ const ChatBox = (
...
@@ -370,12 +371,10 @@ const ChatBox = (
label
:
item
.
value
,
label
:
item
.
value
,
value
:
item
.
value
value
:
item
.
value
}))
}
}))
}
{
...
register
(
item
.
key
,
{
value=
{
getValues
(
item
.
key
)
}
required
:
item
.
required
})}
onchange=
{
(
e
)
=>
{
onchange=
{
(
e
)
=>
{
setValue
(
item
.
key
,
e
);
setValue
(
item
.
key
,
e
);
// setRefresh((state) => !state
);
setRefresh
(
!
refresh
);
}
}
}
}
/>
/>
)
}
)
}
...
@@ -401,7 +400,6 @@ const ChatBox = (
...
@@ -401,7 +400,6 @@ const ChatBox = (
</
Flex
>
</
Flex
>
</
Flex
>
</
Flex
>
)
}
)
}
{
/* empty guide */
}
{
/* chat history */
}
{
/* chat history */
}
<
Box
id=
{
'history'
}
pb=
{
[
8
,
2
]
}
>
<
Box
id=
{
'history'
}
pb=
{
[
8
,
2
]
}
>
...
...
client/src/components/Select/index.tsx
View file @
f5460683
import
React
,
{
useRef
}
from
'react'
;
import
React
,
{
useRef
,
forwardRef
}
from
'react'
;
import
{
import
{
Menu
,
Menu
,
Box
,
Box
,
...
@@ -20,9 +20,12 @@ interface Props extends ButtonProps {
...
@@ -20,9 +20,12 @@ interface Props extends ButtonProps {
onchange
?:
(
val
:
string
)
=>
void
;
onchange
?:
(
val
:
string
)
=>
void
;
}
}
const
MySelect
=
({
placeholder
,
value
,
width
=
'auto'
,
list
,
onchange
,
...
props
}:
Props
)
=>
{
const
MySelect
=
(
const
ref
=
useRef
<
HTMLDivElement
>
(
null
);
{
placeholder
,
value
,
width
=
'auto'
,
list
,
onchange
,
...
props
}:
Props
,
const
SelectRef
=
useRef
(
null
);
selectRef
:
any
)
=>
{
const
ref
=
useRef
<
HTMLButtonElement
>
(
null
);
const
SelectRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
menuItemStyles
=
{
const
menuItemStyles
=
{
borderRadius
:
'sm'
,
borderRadius
:
'sm'
,
py
:
2
,
py
:
2
,
...
@@ -116,4 +119,4 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
...
@@ -116,4 +119,4 @@ const MySelect = ({ placeholder, value, width = 'auto', list, onchange, ...props
);
);
};
};
export
default
React
.
memo
(
MySelect
);
export
default
React
.
memo
(
forwardRef
(
MySelect
)
);
client/src/constants/app.ts
View file @
f5460683
This diff is collapsed.
Click to expand it.
client/src/constants/flow/ModuleTemplate.ts
View file @
f5460683
...
@@ -88,7 +88,7 @@ const defaultModel = chatModelList[0];
...
@@ -88,7 +88,7 @@ const defaultModel = chatModelList[0];
export
const
ChatModule
:
AppModuleTemplateItemType
=
{
export
const
ChatModule
:
AppModuleTemplateItemType
=
{
logo
:
'/imgs/module/AI.png'
,
logo
:
'/imgs/module/AI.png'
,
name
:
'AI 对话'
,
name
:
'AI 对话'
,
intro
:
'
OpenAI GPT 大模型对话。
'
,
intro
:
'
AI 大模型对话
'
,
flowType
:
FlowModuleTypeEnum
.
chatNode
,
flowType
:
FlowModuleTypeEnum
.
chatNode
,
type
:
AppModuleItemTypeEnum
.
http
,
type
:
AppModuleItemTypeEnum
.
http
,
url
:
'/openapi/modules/chat/gpt'
,
url
:
'/openapi/modules/chat/gpt'
,
...
@@ -308,24 +308,24 @@ export const RecognizeIntentionModule: AppModuleTemplateItemType = {
...
@@ -308,24 +308,24 @@ export const RecognizeIntentionModule: AppModuleTemplateItemType = {
value: [
value: [
{
{
value: '',
value: '',
key: '
a
'
key: '
fasw
'
},
},
{
{
value: '',
value: '',
key: '
b
'
key: '
fqsw
'
}
}
]
]
}
}
],
],
outputs: [
outputs: [
{
{
key: '
a
',
key: '
fasw
',
label: '',
label: '',
type: FlowOutputItemTypeEnum.hidden,
type: FlowOutputItemTypeEnum.hidden,
targets: []
targets: []
},
},
{
{
key: '
b
',
key: '
fqsw
',
label: '',
label: '',
type: FlowOutputItemTypeEnum.hidden,
type: FlowOutputItemTypeEnum.hidden,
targets: []
targets: []
...
...
client/src/pages/api/admin/initv4.ts
0 → 100644
View file @
f5460683
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'next'
;
import
{
jsonRes
}
from
'@/service/response'
;
import
{
authUser
}
from
'@/service/utils/auth'
;
import
{
connectToDatabase
,
TrainingData
,
User
,
promotionRecord
}
from
'@/service/mongo'
;
import
{
TrainingModeEnum
}
from
'@/constants/plugin'
;
import
mongoose
from
'mongoose'
;
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
try
{
await
authUser
({
req
,
authRoot
:
true
});
const
{
amount
,
userId
,
type
}
=
req
.
body
as
{
amount
:
number
;
userId
:
number
;
type
:
'withdraw'
;
};
await
connectToDatabase
();
jsonRes
(
res
,
{
data
:
''
});
}
catch
(
error
)
{
jsonRes
(
res
,
{
code
:
500
,
error
});
}
}
client/src/pages/api/openapi/modules/agent/recognizeIntention.ts
View file @
f5460683
...
@@ -18,7 +18,7 @@ export type Props = {
...
@@ -18,7 +18,7 @@ export type Props = {
};
};
export
type
Response
=
{
history
:
ChatItemType
[]
};
export
type
Response
=
{
history
:
ChatItemType
[]
};
const
agentModel
=
'gpt-3.5-turbo'
;
const
agentModel
=
'gpt-3.5-turbo
-16k
'
;
const
agentFunName
=
'agent_user_question'
;
const
agentFunName
=
'agent_user_question'
;
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
...
@@ -75,13 +75,13 @@ export async function classifyQuestion({
...
@@ -75,13 +75,13 @@ export async function classifyQuestion({
// function body
// function body
const
agentFunction
=
{
const
agentFunction
=
{
name
:
agentFunName
,
name
:
agentFunName
,
description
:
'
严格判断用户问题的类型
'
,
description
:
'
判断用户问题的类型,并返回不同的值
'
,
parameters
:
{
parameters
:
{
type
:
'object'
,
type
:
'object'
,
properties
:
{
properties
:
{
type
:
{
type
:
{
type
:
'string'
,
type
:
'string'
,
description
:
agents
.
map
((
item
)
=>
`
${
item
.
value
}
,返回: '
${
item
.
key
}
'`
).
join
(
'
;
'
),
description
:
agents
.
map
((
item
)
=>
`
${
item
.
value
}
,返回: '
${
item
.
key
}
'`
).
join
(
'
\n
'
),
enum
:
agents
.
map
((
item
)
=>
item
.
key
)
enum
:
agents
.
map
((
item
)
=>
item
.
key
)
}
}
},
},
...
...
client/src/pages/app/detail/components/Settings.tsx
View file @
f5460683
...
@@ -73,11 +73,11 @@ const Settings = ({ appId }: { appId: string }) => {
...
@@ -73,11 +73,11 @@ const Settings = ({ appId }: { appId: string }) => {
概览
概览
</
Box
>
</
Box
>
<
Box
<
Box
border=
{
theme
.
borders
.
sm
}
border=
{
theme
.
borders
.
base
}
borderRadius=
{
'lg'
}
borderRadius=
{
'lg'
}
px=
{
5
}
px=
{
5
}
py=
{
4
}
py=
{
4
}
bg=
{
'
rgba(235,245,255,0.4)
'
}
bg=
{
'
myBlue.100
'
}
position=
{
'relative'
}
position=
{
'relative'
}
>
>
<
Flex
alignItems=
{
'center'
}
py=
{
2
}
>
<
Flex
alignItems=
{
'center'
}
py=
{
2
}
>
...
...
client/src/pages/app/detail/components/edit/index.tsx
View file @
f5460683
...
@@ -227,6 +227,8 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
...
@@ -227,6 +227,8 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
const
{
mutate
:
onclickSave
,
isLoading
}
=
useRequest
({
const
{
mutate
:
onclickSave
,
isLoading
}
=
useRequest
({
mutationFn
:
()
=>
{
mutationFn
:
()
=>
{
console
.
log
(
flow2Modules
());
return
putAppById
(
app
.
_id
,
{
return
putAppById
(
app
.
_id
,
{
modules
:
flow2Modules
()
modules
:
flow2Modules
()
});
});
...
@@ -240,8 +242,6 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
...
@@ -240,8 +242,6 @@ const AppEdit = ({ app, fullScreen, onFullScreen }: Props) => {
const
initData
=
useCallback
(
const
initData
=
useCallback
(
(
app
:
AppSchema
)
=>
{
(
app
:
AppSchema
)
=>
{
console
.
log
(
'init'
);
const
edges
=
appModule2FlowEdge
({
const
edges
=
appModule2FlowEdge
({
modules
:
app
.
modules
,
modules
:
app
.
modules
,
onDelete
:
onDelConnect
onDelete
:
onDelConnect
...
...
client/src/pages/app/list/component/CreateModal.tsx
View file @
f5460683
...
@@ -105,7 +105,9 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
...
@@ -105,7 +105,9 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
<
ModalContent
w=
{
'700px'
}
maxW=
{
'90vw'
}
>
<
ModalContent
w=
{
'700px'
}
maxW=
{
'90vw'
}
>
<
ModalHeader
fontSize=
{
'2xl'
}
>
开始创建你的 AI 应用
</
ModalHeader
>
<
ModalHeader
fontSize=
{
'2xl'
}
>
开始创建你的 AI 应用
</
ModalHeader
>
<
ModalBody
>
<
ModalBody
>
<
Box
color=
{
'myGray.800'
}
>
取个响亮的名字
</
Box
>
<
Box
color=
{
'myGray.800'
}
fontWeight=
{
'bold'
}
>
取个响亮的名字
</
Box
>
<
Flex
mt=
{
3
}
alignItems=
{
'center'
}
>
<
Flex
mt=
{
3
}
alignItems=
{
'center'
}
>
<
Avatar
<
Avatar
src=
{
getValues
(
'avatar'
)
}
src=
{
getValues
(
'avatar'
)
}
...
@@ -124,7 +126,7 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
...
@@ -124,7 +126,7 @@ const CreateModal = ({ onClose, onSuccess }: { onClose: () => void; onSuccess: (
})}
})}
/>
/>
</
Flex
>
</
Flex
>
<
Box
mt=
{
7
}
mb=
{
3
}
color=
{
'myGray.800'
}
>
<
Box
mt=
{
7
}
mb=
{
3
}
color=
{
'myGray.800'
}
fontWeight=
{
'bold'
}
>
从模板中选择
从模板中选择
</
Box
>
</
Box
>
<
Grid
<
Grid
...
...
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