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
6c62d80a
authored
Jun 18, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: refresh page
parent
ff2043c0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
14 deletions
+17
-14
client/public/docs/versionIntro.md
+7
-4
client/src/pages/api/openapi/v1/chat/completions.ts
+1
-1
client/src/pages/model/components/detail/components/Settings.tsx
+2
-0
client/src/utils/adapt.ts
+5
-3
client/src/utils/plugin/openai.ts
+2
-6
No files found.
client/public/docs/versionIntro.md
View file @
6c62d80a
### Fast GPT V3.8.
4
### Fast GPT V3.8.
8
1.
新增 - mermaid 导图兼容,可以在应用市场 'mermaid 导图' 进行体验。
2.
优化 - 部分 UI 和账号页。
2.
优化 - 知识库搜索速度
1.
新增 - V2 版 OpenAPI,可以在任意第三方套壳 ChatGpt 项目中直接使用 FastGpt 的应用,注意!是直接。
2.
新增 - 应用配置最大回复长度。
3.
新增 - 更多的知识库配置项:相似度、最大搜索数量、自定义空搜索结果回复。
4.
新增 - 知识库搜索测试,方便调试。
5.
优化 - 知识库提示词位置,拥有更强的引导。
6.
优化 - 应用编辑页面。
client/src/pages/api/openapi/v1/chat/completions.ts
View file @
6c62d80a
import
type
{
NextApiRequest
,
NextApiResponse
}
from
'next'
;
import
{
connectToDatabase
}
from
'@/service/mongo'
;
import
{
authUser
,
authModel
,
getApiKey
,
authShareChat
,
type
AuthType
}
from
'@/service/utils/auth'
;
import
{
authUser
,
authModel
,
getApiKey
,
authShareChat
}
from
'@/service/utils/auth'
;
import
{
modelServiceToolMap
,
V2_StreamResponse
}
from
'@/service/utils/chat'
;
import
{
jsonRes
}
from
'@/service/response'
;
import
{
ChatModelMap
}
from
'@/constants/model'
;
...
...
client/src/pages/model/components/detail/components/Settings.tsx
View file @
6c62d80a
...
...
@@ -156,6 +156,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
onSuccess
(
res
)
{
res
&&
reset
(
res
);
modelId
&&
setLastModelId
(
modelId
);
setRefresh
(
!
refresh
);
},
onError
(
err
:
any
)
{
toast
({
...
...
@@ -278,6 +279,7 @@ const Settings = ({ modelId }: { modelId: string }) => {
width=
{
[
'100%'
,
'260px'
]
}
min=
{
100
}
max=
{
tokenLimit
}
step=
{
50
}
activeVal=
{
getValues
(
'chat.maxToken'
)
}
setVal=
{
(
val
)
=>
{
setValue
(
'chat.maxToken'
,
val
);
...
...
client/src/utils/adapt.ts
View file @
6c62d80a
...
...
@@ -20,15 +20,17 @@ export const adaptBill = (bill: BillSchema): UserBillType => {
};
export
const
gptMessage2ChatType
=
(
messages
:
MessageItemType
[]):
ChatItemType
[]
=>
{
const
roleMap
=
{
const
roleMap
:
Record
<
`
${
ChatCompletionRequestMessageRoleEnum
}
`
,
`
${
ChatRoleEnum
}
`
>
=
{
[
ChatCompletionRequestMessageRoleEnum
.
Assistant
]:
ChatRoleEnum
.
AI
,
[
ChatCompletionRequestMessageRoleEnum
.
User
]:
ChatRoleEnum
.
Human
,
[
ChatCompletionRequestMessageRoleEnum
.
System
]:
ChatRoleEnum
.
System
[
ChatCompletionRequestMessageRoleEnum
.
System
]:
ChatRoleEnum
.
System
,
[
ChatCompletionRequestMessageRoleEnum
.
Function
]:
ChatRoleEnum
.
Human
};
return
messages
.
map
((
item
)
=>
({
_id
:
item
.
_id
,
obj
:
roleMap
[
item
.
role
],
value
:
item
.
content
value
:
item
.
content
||
''
}));
};
...
...
client/src/utils/plugin/openai.ts
View file @
6c62d80a
import
{
encoding_for_model
,
type
Tiktoken
}
from
'@dqbd/tiktoken'
;
import
type
{
ChatItemType
}
from
'@/types/chat'
;
import
{
ChatRoleEnum
}
from
'@/constants/chat'
;
import
{
ChatCompletionRequestMessageRoleEnum
}
from
'openai'
;
import
{
type
ChatCompletionRequestMessage
,
ChatCompletionRequestMessageRoleEnum
}
from
'openai'
;
import
{
OpenAiChatEnum
}
from
'@/constants/model'
;
import
Graphemer
from
'graphemer'
;
import
axios
from
'axios'
;
...
...
@@ -113,11 +113,7 @@ export function countOpenAIToken({
model
:
`
${
OpenAiChatEnum
}
`
;
})
{
function
getChatGPTEncodingText
(
messages
:
{
role
:
'system'
|
'user'
|
'assistant'
;
content
:
string
;
name
?:
string
;
}[],
messages
:
ChatCompletionRequestMessage
[],
model
:
`
${
OpenAiChatEnum
}
`
)
{
const
isGpt3
=
model
.
startsWith
(
'gpt-3.5-turbo'
);
...
...
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