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
e5e720e8
authored
Jul 25, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: chat model show
parent
35718b1f
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
73 additions
and
53 deletions
+73
-53
client/src/api/response/chat.d.ts
+3
-8
client/src/components/ChatBox/index.tsx
+0
-17
client/src/components/ChatBox/utils.ts
+29
-0
client/src/components/Icon/icons/light/chatModelTag.svg
+2
-0
client/src/components/Icon/index.tsx
+2
-1
client/src/components/Tag/index.tsx
+9
-8
client/src/pages/api/chat/init.ts
+2
-1
client/src/pages/api/chat/shareChat/init.ts
+2
-1
client/src/pages/app/detail/components/AdEdit/components/ChatTest.tsx
+2
-5
client/src/pages/app/detail/components/BasicEdit/index.tsx
+3
-5
client/src/pages/chat/components/ChatHeader.tsx
+14
-3
client/src/pages/chat/index.tsx
+1
-0
client/src/service/utils/data.ts
+4
-4
No files found.
client/src/api/response/chat.d.ts
View file @
e5e720e8
...
@@ -8,10 +8,11 @@ export interface InitChatResponse {
...
@@ -8,10 +8,11 @@ export interface InitChatResponse {
app
:
{
app
:
{
variableModules
?:
VariableItemType
[];
variableModules
?:
VariableItemType
[];
welcomeText
?:
string
;
welcomeText
?:
string
;
chatModels
?:
string
[];
name
:
string
;
name
:
string
;
avatar
:
string
;
avatar
:
string
;
intro
:
string
;
intro
:
string
;
canUse
:
boolean
;
canUse
?
:
boolean
;
};
};
title
:
string
;
title
:
string
;
variables
:
Record
<
string
,
any
>
;
variables
:
Record
<
string
,
any
>
;
...
@@ -20,11 +21,5 @@ export interface InitChatResponse {
...
@@ -20,11 +21,5 @@ export interface InitChatResponse {
export
interface
InitShareChatResponse
{
export
interface
InitShareChatResponse
{
userAvatar
:
string
;
userAvatar
:
string
;
app
:
{
app
:
InitChatResponse
[
'app'
];
variableModules
?:
VariableItemType
[];
welcomeText
?:
string
;
name
:
string
;
avatar
:
string
;
intro
:
string
;
};
}
}
client/src/components/ChatBox/index.tsx
View file @
e5e720e8
...
@@ -817,20 +817,3 @@ export const useChatBox = () => {
...
@@ -817,20 +817,3 @@ export const useChatBox = () => {
onExportChat
onExportChat
}
;
}
;
};
};
export const getSpecialModule = (modules: AppModuleItemType[]) =
>
{
const
welcomeText
:
string
=
modules
.
find
((
item
)
=>
item
.
flowType
===
FlowModuleTypeEnum
.
userGuide
)
?.
inputs
?.
find
((
item
)
=>
item
.
key
===
SystemInputEnum
.
welcomeText
)?.
value
||
''
;
const
variableModules
:
VariableItemType
[]
=
modules
.
find
((
item
)
=>
item
.
flowType
===
FlowModuleTypeEnum
.
variable
)
?.
inputs
.
find
((
item
)
=>
item
.
key
===
SystemInputEnum
.
variables
)?.
value
||
[];
return
{
welcomeText
,
variableModules
};
}
;
client/src/components/ChatBox/utils.ts
0 → 100644
View file @
e5e720e8
import
{
SystemInputEnum
}
from
'@/constants/app'
;
import
{
FlowModuleTypeEnum
}
from
'@/constants/flow'
;
import
{
getChatModel
}
from
'@/service/utils/data'
;
import
{
AppModuleItemType
,
VariableItemType
}
from
'@/types/app'
;
export
const
getSpecialModule
=
(
modules
:
AppModuleItemType
[])
=>
{
const
welcomeText
:
string
=
modules
.
find
((
item
)
=>
item
.
flowType
===
FlowModuleTypeEnum
.
userGuide
)
?.
inputs
?.
find
((
item
)
=>
item
.
key
===
SystemInputEnum
.
welcomeText
)?.
value
||
''
;
const
variableModules
:
VariableItemType
[]
=
modules
.
find
((
item
)
=>
item
.
flowType
===
FlowModuleTypeEnum
.
variable
)
?.
inputs
.
find
((
item
)
=>
item
.
key
===
SystemInputEnum
.
variables
)?.
value
||
[];
return
{
welcomeText
,
variableModules
};
};
export
const
getChatModelNameList
=
(
modules
:
AppModuleItemType
[]):
string
[]
=>
{
const
chatModules
=
modules
.
filter
((
item
)
=>
item
.
flowType
===
FlowModuleTypeEnum
.
chatNode
);
return
chatModules
.
map
(
(
item
)
=>
getChatModel
(
item
.
inputs
.
find
((
input
)
=>
input
.
key
===
'model'
)?.
value
)?.
name
||
''
)
.
filter
((
item
)
=>
item
);
};
client/src/components/Icon/icons/light/chatModelTag.svg
0 → 100644
View file @
e5e720e8
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1690272002242"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"9773"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"64"
height=
"64"
><path
d=
"M554.666667 251.733333V341.333333h341.333333v426.666667H170.666667V341.333333h341.333333V251.733333c-25.6-8.533333-42.666667-34.133333-42.666667-59.733333 0-34.133333 29.866667-64 64-64s64 29.866667 64 64c0 29.866667-17.066667 51.2-42.666666 59.733333zM512 384H213.333333v341.333333h640V384h-341.333333z m-384 85.333333v213.333334H85.333333v-213.333334h42.666667z m853.333333 0v213.333334h-42.666666v-213.333334h42.666666zM384 597.333333c-25.6 0-42.666667-17.066667-42.666667-42.666666s17.066667-42.666667 42.666667-42.666667 42.666667 17.066667 42.666667 42.666667-17.066667 42.666667-42.666667 42.666666z m298.666667 0c-25.6 0-42.666667-17.066667-42.666667-42.666666s17.066667-42.666667 42.666667-42.666667 42.666667 17.066667 42.666666 42.666667-17.066667 42.666667-42.666666 42.666666z"
p-id=
"9774"
></path></svg>
\ No newline at end of file
client/src/components/Icon/index.tsx
View file @
e5e720e8
...
@@ -67,7 +67,8 @@ const map = {
...
@@ -67,7 +67,8 @@ const map = {
billRecordLight
:
require
(
'./icons/light/billRecord.svg'
).
default
,
billRecordLight
:
require
(
'./icons/light/billRecord.svg'
).
default
,
informLight
:
require
(
'./icons/light/inform.svg'
).
default
,
informLight
:
require
(
'./icons/light/inform.svg'
).
default
,
payRecordLight
:
require
(
'./icons/light/payRecord.svg'
).
default
,
payRecordLight
:
require
(
'./icons/light/payRecord.svg'
).
default
,
loginoutLight
:
require
(
'./icons/light/loginout.svg'
).
default
loginoutLight
:
require
(
'./icons/light/loginout.svg'
).
default
,
chatModelTag
:
require
(
'./icons/light/chatModelTag.svg'
).
default
};
};
export
type
IconName
=
keyof
typeof
map
;
export
type
IconName
=
keyof
typeof
map
;
...
...
client/src/components/Tag/index.tsx
View file @
e5e720e8
import
React
,
{
useMemo
}
from
'react'
;
import
React
,
{
useMemo
}
from
'react'
;
import
{
Box
,
type
Bo
xProps
}
from
'@chakra-ui/react'
;
import
{
Flex
,
type
Fle
xProps
}
from
'@chakra-ui/react'
;
interface
Props
extends
Bo
xProps
{
interface
Props
extends
Fle
xProps
{
children
:
React
.
ReactNode
|
React
.
ReactNode
[];
children
:
React
.
ReactNode
|
React
.
ReactNode
[];
colorSchema
?:
'blue'
|
'green'
|
'gray'
;
colorSchema
?:
'blue'
|
'green'
|
'gray'
;
}
}
...
@@ -15,9 +15,9 @@ const Tag = ({ children, colorSchema = 'blue', ...props }: Props) => {
...
@@ -15,9 +15,9 @@ const Tag = ({ children, colorSchema = 'blue', ...props }: Props) => {
color
:
'myBlue.700'
color
:
'myBlue.700'
},
},
green
:
{
green
:
{
borderColor
:
'#5
2C41A
'
,
borderColor
:
'#5
4cd19
'
,
bg
:
'#
EDFFED
'
,
bg
:
'#
f2fcf2
'
,
color
:
'#5
2C41A
'
color
:
'#5
4cd19
'
},
},
gray
:
{
gray
:
{
borderColor
:
'#979797'
,
borderColor
:
'#979797'
,
...
@@ -27,20 +27,21 @@ const Tag = ({ children, colorSchema = 'blue', ...props }: Props) => {
...
@@ -27,20 +27,21 @@ const Tag = ({ children, colorSchema = 'blue', ...props }: Props) => {
};
};
return
map
[
colorSchema
];
return
map
[
colorSchema
];
},
[
colorSchema
]);
},
[
colorSchema
]);
return
(
return
(
<
Box
<
Flex
display=
{
'inline-block'
}
border=
{
'1px solid'
}
border=
{
'1px solid'
}
px=
{
2
}
px=
{
2
}
lineHeight=
{
1
}
lineHeight=
{
1
}
py=
{
1
}
py=
{
1
}
borderRadius=
{
'md'
}
borderRadius=
{
'md'
}
fontSize=
{
'xs'
}
fontSize=
{
'xs'
}
alignItems=
{
'center'
}
{
...
theme
}
{
...
theme
}
{
...
props
}
{
...
props
}
>
>
{
children
}
{
children
}
</
Bo
x
>
</
Fle
x
>
);
);
};
};
...
...
client/src/pages/api/chat/init.ts
View file @
e5e720e8
...
@@ -7,7 +7,7 @@ import { ChatItemType } from '@/types/chat';
...
@@ -7,7 +7,7 @@ import { ChatItemType } from '@/types/chat';
import
{
authApp
}
from
'@/service/utils/auth'
;
import
{
authApp
}
from
'@/service/utils/auth'
;
import
mongoose
from
'mongoose'
;
import
mongoose
from
'mongoose'
;
import
type
{
ChatSchema
}
from
'@/types/mongoSchema'
;
import
type
{
ChatSchema
}
from
'@/types/mongoSchema'
;
import
{
getSpecialModule
}
from
'@/components/ChatBox
'
;
import
{
getSpecialModule
,
getChatModelNameList
}
from
'@/components/ChatBox/utils
'
;
import
{
TaskResponseKeyEnum
}
from
'@/constants/chat'
;
import
{
TaskResponseKeyEnum
}
from
'@/constants/chat'
;
/* 初始化我的聊天框,需要身份验证 */
/* 初始化我的聊天框,需要身份验证 */
...
@@ -90,6 +90,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -90,6 +90,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
appId
,
appId
,
app
:
{
app
:
{
...
getSpecialModule
(
app
.
modules
),
...
getSpecialModule
(
app
.
modules
),
chatModels
:
getChatModelNameList
(
app
.
modules
),
name
:
app
.
name
,
name
:
app
.
name
,
avatar
:
app
.
avatar
,
avatar
:
app
.
avatar
,
intro
:
app
.
intro
,
intro
:
app
.
intro
,
...
...
client/src/pages/api/chat/shareChat/init.ts
View file @
e5e720e8
...
@@ -4,7 +4,7 @@ import { connectToDatabase, ShareChat, User } from '@/service/mongo';
...
@@ -4,7 +4,7 @@ import { connectToDatabase, ShareChat, User } from '@/service/mongo';
import
type
{
InitShareChatResponse
}
from
'@/api/response/chat'
;
import
type
{
InitShareChatResponse
}
from
'@/api/response/chat'
;
import
{
authApp
}
from
'@/service/utils/auth'
;
import
{
authApp
}
from
'@/service/utils/auth'
;
import
{
HUMAN_ICON
}
from
'@/constants/chat'
;
import
{
HUMAN_ICON
}
from
'@/constants/chat'
;
import
{
get
SpecialModule
}
from
'@/components/ChatBox
'
;
import
{
get
ChatModelNameList
,
getSpecialModule
}
from
'@/components/ChatBox/utils
'
;
/* 初始化我的聊天框,需要身份验证 */
/* 初始化我的聊天框,需要身份验证 */
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
export
default
async
function
handler
(
req
:
NextApiRequest
,
res
:
NextApiResponse
)
{
...
@@ -44,6 +44,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -44,6 +44,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
userAvatar
:
user
?.
avatar
||
HUMAN_ICON
,
userAvatar
:
user
?.
avatar
||
HUMAN_ICON
,
app
:
{
app
:
{
...
getSpecialModule
(
app
.
modules
),
...
getSpecialModule
(
app
.
modules
),
chatModels
:
getChatModelNameList
(
app
.
modules
),
name
:
app
.
name
,
name
:
app
.
name
,
avatar
:
app
.
avatar
,
avatar
:
app
.
avatar
,
intro
:
app
.
intro
intro
:
app
.
intro
...
...
client/src/pages/app/detail/components/AdEdit/components/ChatTest.tsx
View file @
e5e720e8
...
@@ -14,11 +14,8 @@ import { FlowModuleTypeEnum } from '@/constants/flow';
...
@@ -14,11 +14,8 @@ import { FlowModuleTypeEnum } from '@/constants/flow';
import
{
streamFetch
}
from
'@/api/fetch'
;
import
{
streamFetch
}
from
'@/api/fetch'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
ChatBox
,
{
import
ChatBox
,
{
type
ComponentRef
,
type
StartChatFnProps
}
from
'@/components/ChatBox'
;
getSpecialModule
,
import
{
getSpecialModule
}
from
'@/components/ChatBox/utils'
;
type
ComponentRef
,
type
StartChatFnProps
}
from
'@/components/ChatBox'
;
export
type
ChatTestComponentRef
=
{
export
type
ChatTestComponentRef
=
{
resetChatTest
:
()
=>
void
;
resetChatTest
:
()
=>
void
;
...
...
client/src/pages/app/detail/components/BasicEdit/index.tsx
View file @
e5e720e8
...
@@ -51,11 +51,9 @@ import MySlider from '@/components/Slider';
...
@@ -51,11 +51,9 @@ import MySlider from '@/components/Slider';
import
MyTooltip
from
'@/components/MyTooltip'
;
import
MyTooltip
from
'@/components/MyTooltip'
;
import
Avatar
from
'@/components/Avatar'
;
import
Avatar
from
'@/components/Avatar'
;
import
MyIcon
from
'@/components/Icon'
;
import
MyIcon
from
'@/components/Icon'
;
import
ChatBox
,
{
import
ChatBox
,
{
type
ComponentRef
,
type
StartChatFnProps
}
from
'@/components/ChatBox'
;
getSpecialModule
,
import
{
getSpecialModule
}
from
'@/components/ChatBox/utils'
;
type
ComponentRef
,
type
StartChatFnProps
}
from
'@/components/ChatBox'
;
import
{
addVariable
}
from
'../VariableEditModal'
;
import
{
addVariable
}
from
'../VariableEditModal'
;
import
{
KBSelectModal
,
KbParamsModal
}
from
'../KBSelectModal'
;
import
{
KBSelectModal
,
KbParamsModal
}
from
'../KBSelectModal'
;
...
...
client/src/pages/chat/components/ChatHeader.tsx
View file @
e5e720e8
...
@@ -11,16 +11,21 @@ const ChatHeader = ({
...
@@ -11,16 +11,21 @@ const ChatHeader = ({
history
,
history
,
appName
,
appName
,
appAvatar
,
appAvatar
,
chatModels
,
onOpenSlider
onOpenSlider
}:
{
}:
{
history
:
ChatItemType
[];
history
:
ChatItemType
[];
appName
:
string
;
appName
:
string
;
appAvatar
:
string
;
appAvatar
:
string
;
chatModels
?:
string
[];
onOpenSlider
:
()
=>
void
;
onOpenSlider
:
()
=>
void
;
})
=>
{
})
=>
{
const
theme
=
useTheme
();
const
theme
=
useTheme
();
const
{
isPc
}
=
useGlobalStore
();
const
{
isPc
}
=
useGlobalStore
();
const
title
=
useMemo
(()
=>
{},
[]);
const
title
=
useMemo
(
()
=>
history
[
history
.
length
-
2
]?.
value
?.
slice
(
0
,
8
)
||
appName
||
'新对话'
,
[
appName
,
history
]
);
return
(
return
(
<
Flex
<
Flex
...
@@ -34,12 +39,18 @@ const ChatHeader = ({
...
@@ -34,12 +39,18 @@ const ChatHeader = ({
{
isPc
?
(
{
isPc
?
(
<>
<>
<
Box
mr=
{
3
}
color=
{
'myGray.1000'
}
>
<
Box
mr=
{
3
}
color=
{
'myGray.1000'
}
>
{
appNam
e
}
{
titl
e
}
</
Box
>
</
Box
>
<
Tag
display=
{
'flex'
}
>
<
Tag
>
<
MyIcon
name=
{
'history'
}
w=
{
'14px'
}
/>
<
MyIcon
name=
{
'history'
}
w=
{
'14px'
}
/>
<
Box
ml=
{
1
}
>
{
history
.
length
===
0
?
'新的对话'
:
`${history.length}条记录`
}
</
Box
>
<
Box
ml=
{
1
}
>
{
history
.
length
===
0
?
'新的对话'
:
`${history.length}条记录`
}
</
Box
>
</
Tag
>
</
Tag
>
{
!!
chatModels
&&
(
<
Tag
ml=
{
2
}
colorSchema=
{
'green'
}
>
<
MyIcon
name=
{
'chatModelTag'
}
w=
{
'14px'
}
/>
<
Box
ml=
{
1
}
>
{
chatModels
.
join
(
','
)
}
</
Box
>
</
Tag
>
)
}
<
Box
flex=
{
1
}
/>
<
Box
flex=
{
1
}
/>
</>
</>
)
:
(
)
:
(
...
...
client/src/pages/chat/index.tsx
View file @
e5e720e8
...
@@ -307,6 +307,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
...
@@ -307,6 +307,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
appAvatar=
{
chatData
.
app
.
avatar
}
appAvatar=
{
chatData
.
app
.
avatar
}
appName=
{
chatData
.
app
.
name
}
appName=
{
chatData
.
app
.
name
}
history=
{
chatData
.
history
}
history=
{
chatData
.
history
}
chatModels=
{
chatData
.
app
.
chatModels
}
onOpenSlider=
{
onOpenSlider
}
onOpenSlider=
{
onOpenSlider
}
/>
/>
...
...
client/src/service/utils/data.ts
View file @
e5e720e8
export
const
getChatModel
=
(
model
:
string
)
=>
{
export
const
getChatModel
=
(
model
?
:
string
)
=>
{
return
global
.
chatModels
.
find
((
item
)
=>
item
.
model
===
model
);
return
global
.
chatModels
.
find
((
item
)
=>
item
.
model
===
model
);
};
};
export
const
getVectorModel
=
(
model
:
string
)
=>
{
export
const
getVectorModel
=
(
model
?
:
string
)
=>
{
return
global
.
vectorModels
.
find
((
item
)
=>
item
.
model
===
model
);
return
global
.
vectorModels
.
find
((
item
)
=>
item
.
model
===
model
);
};
};
export
const
getQAModel
=
(
model
:
string
)
=>
{
export
const
getQAModel
=
(
model
?
:
string
)
=>
{
return
global
.
qaModels
.
find
((
item
)
=>
item
.
model
===
model
);
return
global
.
qaModels
.
find
((
item
)
=>
item
.
model
===
model
);
};
};
export
const
getModel
=
(
model
:
string
)
=>
{
export
const
getModel
=
(
model
?
:
string
)
=>
{
return
[...
global
.
chatModels
,
...
global
.
vectorModels
,
...
global
.
qaModels
].
find
(
return
[...
global
.
chatModels
,
...
global
.
vectorModels
,
...
global
.
qaModels
].
find
(
(
item
)
=>
item
.
model
===
model
(
item
)
=>
item
.
model
===
model
);
);
...
...
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