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
ef2de489
authored
May 09, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: paging position
parent
cb3b9efc
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
22 deletions
+31
-22
src/components/Layout/index.tsx
+1
-1
src/pages/api/chat/chat.ts
+6
-2
src/pages/model/components/detail/components/ModelDataCard.tsx
+2
-2
src/pages/model/share/index.tsx
+2
-2
src/pages/number/components/BillTable.tsx
+3
-3
src/pages/promotion/index.tsx
+2
-2
src/service/plugins/searchKb.ts
+15
-10
No files found.
src/components/Layout/index.tsx
View file @
ef2de489
...
...
@@ -35,7 +35,7 @@ const Layout = ({ children, isPcDevice }: { children: JSX.Element; isPcDevice: b
return
(
<>
<
Box
h=
{
'100%'
}
overflow
=
{
'overlay
'
}
bg=
{
'gray.100'
}
>
<
Box
h=
{
'100%'
}
overflow
Y=
{
'auto
'
}
bg=
{
'gray.100'
}
>
{
isPc
?
(
pcUnShowLayoutRoute
[
router
.
pathname
]
?
(
<
Auth
>
{
children
}
</
Auth
>
...
...
src/pages/api/chat/chat.ts
View file @
ef2de489
...
...
@@ -103,8 +103,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
stream
,
chatResponse
:
streamResponse
,
prompts
,
systemPrompt
:
showModelDetail
&&
prompts
[
0
].
obj
===
ChatRoleEnum
.
System
?
prompts
[
0
].
value
:
''
systemPrompt
:
showModelDetail
?
prompts
.
filter
((
item
)
=>
item
.
obj
===
ChatRoleEnum
.
System
)
.
map
((
item
)
=>
item
.
value
)
.
join
(
'\n'
)
:
''
});
// 只有使用平台的 key 才计费
...
...
src/pages/model/components/detail/components/ModelDataCard.tsx
View file @
ef2de489
...
...
@@ -279,9 +279,9 @@ const ModelDataCard = ({ modelId, isOwner }: { modelId: string; isOwner: boolean
</
Tbody
>
</
Table
>
</
TableContainer
>
<
Box
mt=
{
2
}
textAlign=
{
'
end'
}
>
<
Flex
mt=
{
2
}
justifyContent=
{
'flex-
end'
}
>
<
Pagination
/>
</
Bo
x
>
</
Fle
x
>
</
Box
>
<
Loading
loading=
{
isLoading
}
fixed=
{
false
}
/>
...
...
src/pages/model/share/index.tsx
View file @
ef2de489
...
...
@@ -101,9 +101,9 @@ const modelList = () => {
<
Grid
templateColumns=
{
[
'1fr'
,
'1fr 1fr'
,
'1fr 1fr 1fr'
]
}
gridGap=
{
4
}
mt=
{
4
}
>
<
ShareModelList
models=
{
models
}
onclickCollection=
{
onclickCollection
}
/>
</
Grid
>
<
Box
mt=
{
4
}
>
<
Flex
mt=
{
4
}
justifyContent=
{
'flex-end'
}
>
<
Pagination
/>
</
Bo
x
>
</
Fle
x
>
</
Card
>
<
Loading
loading=
{
isLoading
}
/>
...
...
src/pages/number/components/BillTable.tsx
View file @
ef2de489
import
React
from
'react'
;
import
{
Card
,
Box
,
Table
,
Thead
,
Tbody
,
Tr
,
Th
,
Td
,
TableContainer
}
from
'@chakra-ui/react'
;
import
{
Card
,
Box
,
Table
,
Thead
,
Tbody
,
Tr
,
Th
,
Td
,
TableContainer
,
Flex
}
from
'@chakra-ui/react'
;
import
{
BillTypeMap
}
from
'@/constants/user'
;
import
{
getUserBills
}
from
'@/api/user'
;
import
type
{
UserBillType
}
from
'@/types/user'
;
...
...
@@ -48,9 +48,9 @@ const BillTable = () => {
<
Loading
loading=
{
isLoading
}
fixed=
{
false
}
/>
</
TableContainer
>
<
Box
mt=
{
4
}
mr=
{
4
}
textAlign=
{
'
end'
}
>
<
Flex
mt=
{
4
}
px=
{
4
}
justifyContent=
{
'flex-
end'
}
>
<
Pagination
/>
</
Bo
x
>
</
Fle
x
>
</
Card
>
);
};
...
...
src/pages/promotion/index.tsx
View file @
ef2de489
...
...
@@ -139,9 +139,9 @@ const OpenApi = () => {
<
Loading
loading=
{
isLoading
}
fixed=
{
false
}
/>
</
TableContainer
>
<
Box
mt=
{
4
}
mr=
{
4
}
textAlign=
{
'
end'
}
>
<
Flex
mt=
{
4
}
px=
{
4
}
justifyContent=
{
'flex-
end'
}
>
<
Pagination
/>
</
Bo
x
>
</
Fle
x
>
</
Card
>
<
Modal
isOpen=
{
isOpenWithdraw
}
onClose=
{
onCloseWithdraw
}
>
<
ModalOverlay
/>
...
...
src/service/plugins/searchKb.ts
View file @
ef2de489
...
...
@@ -85,7 +85,8 @@ export const searchKb = async ({
};
const
filterRate
=
filterRateMap
[
systemPrompts
.
length
]
||
filterRateMap
[
0
];
const
filterPrompts
=
[
// 计算固定提示词的 token 数量
const
fixedPrompts
=
[
...(
model
.
chat
.
systemPrompt
?
[
{
...
...
@@ -94,22 +95,26 @@ export const searchKb = async ({
}
]
:
[]),
...(
model
.
chat
.
searchMode
!
==
ModelVectorSearchModeEnum
.
noContext
...(
model
.
chat
.
searchMode
=
==
ModelVectorSearchModeEnum
.
noContext
?
[
{
obj
:
ChatRoleEnum
.
System
,
value
:
`知识库是关于"
${
model
.
name
}
"的内容,根据知识库内容回答问题.`
}
]
:
[
{
obj
:
ChatRoleEnum
.
System
,
value
:
`我们来玩问答游戏,规则为:
1.你完全忘记你已有的知识
2.你只能回答关于"
${
model
.
name
}
"的问题
3.你只能从知识库中选择内容进行回答
4.如果问题不在知识库中,你会回答"我不知道。"
1.你只能回答关于"
${
model
.
name
}
"的问题
2.你只能从知识库中选择内容进行回答
3.如果问题不在知识库中,你会回答"我不知道。"
务必遵守规则`
}
]
:
[])
])
];
const
fixedSystemTokens
=
modelToolMap
[
model
.
chat
.
chatModel
].
countTokens
({
messages
:
fi
lter
Prompts
messages
:
fi
xed
Prompts
});
const
maxTokens
=
modelConstantsData
.
systemMaxToken
-
fixedSystemTokens
;
...
...
@@ -157,7 +162,7 @@ export const searchKb = async ({
obj
:
ChatRoleEnum
.
System
,
value
:
`知识库:'
${
filterSystemPrompt
}
'`
},
...
fi
lter
Prompts
...
fi
xed
Prompts
]
};
};
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