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
ba965320
authored
Jul 23, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: openapi
parent
67e10d6f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
17 deletions
+11
-17
client/src/pages/api/openapi/v1/chat/completions.ts
+9
-1
client/src/pages/chat/share.tsx
+1
-1
client/src/service/moduleDispatch/chat/oneapi.ts
+1
-15
No files found.
client/src/pages/api/openapi/v1/chat/completions.ts
View file @
ba965320
...
...
@@ -13,7 +13,7 @@ import {
dispatchClassifyQuestion
}
from
'@/service/moduleDispatch'
;
import
type
{
CreateChatCompletionRequest
}
from
'openai'
;
import
{
gptMessage2ChatType
}
from
'@/utils/adapt'
;
import
{
gptMessage2ChatType
,
textAdaptGptResponse
}
from
'@/utils/adapt'
;
import
{
getChatHistory
}
from
'./getHistory'
;
import
{
saveChat
}
from
'@/service/utils/chat/saveChat'
;
import
{
sseResponse
}
from
'@/service/utils/tools'
;
...
...
@@ -157,6 +157,14 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
sseResponse
({
res
,
event
:
sseResponseEventEnum
.
answer
,
data
:
textAdaptGptResponse
({
text
:
null
,
finish_reason
:
'stop'
})
});
sseResponse
({
res
,
event
:
sseResponseEventEnum
.
answer
,
data
:
'[DONE]'
});
...
...
client/src/pages/chat/share.tsx
View file @
ba965320
...
...
@@ -169,7 +169,7 @@ const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) =>
onChangeChat=
{
(
chatId
)
=>
{
console
.
log
(
chatId
);
router
.
push
({
router
.
replace
({
query
:
{
chatId
:
chatId
||
''
,
shareId
...
...
client/src/service/moduleDispatch/chat/oneapi.ts
View file @
ba965320
...
...
@@ -209,21 +209,7 @@ async function streamResponse({ res, response }: { res: NextApiResponse; respons
if
(
res
.
closed
||
error
)
return
;
if
(
data
===
'[DONE]'
)
{
sseResponse
({
res
,
event
:
sseResponseEventEnum
.
answer
,
data
:
textAdaptGptResponse
({
text
:
null
,
finish_reason
:
'stop'
})
});
sseResponse
({
res
,
event
:
sseResponseEventEnum
.
answer
,
data
:
'[DONE]'
});
}
else
{
if
(
data
!==
'[DONE]'
)
{
sseResponse
({
res
,
event
:
sseResponseEventEnum
.
answer
,
...
...
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