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
30678d8e
authored
Mar 24, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: destroy后仍有push流
parent
6ce727f9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
9 deletions
+4
-9
src/pages/api/chat/chatGpt.ts
+4
-3
src/service/events/bill.ts
+0
-6
No files found.
src/pages/api/chat/chatGpt.ts
View file @
30678d8e
...
...
@@ -121,7 +121,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if
(
!
content
)
return
;
responseContent
+=
content
;
// console.log('content:', content)
stream
.
push
(
content
.
replace
(
/
\n
/g
,
'<br/>'
));
!
stream
.
destroyed
&&
stream
.
push
(
content
.
replace
(
/
\n
/g
,
'<br/>'
));
}
catch
(
error
)
{
error
;
}
...
...
@@ -140,7 +140,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
catch
(
error
)
{
console
.
log
(
'pipe error'
,
error
);
}
stream
.
push
(
null
);
// close stream
stream
.
destroy
();
const
promptsLen
=
formatPrompts
.
reduce
((
sum
,
item
)
=>
sum
+
item
.
content
.
length
,
0
);
console
.
log
(
`responseLen:
${
responseContent
.
length
}
`
,
`promptLen:
${
promptsLen
}
`
);
...
...
@@ -154,8 +155,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
});
}
catch
(
err
:
any
)
{
if
(
step
===
1
)
{
console
.
log
(
'error,结束'
);
// 直接结束流
console
.
log
(
'error,结束'
);
stream
.
destroy
();
}
else
{
res
.
status
(
500
);
...
...
src/service/events/bill.ts
View file @
30678d8e
...
...
@@ -14,15 +14,9 @@ export const pushBill = async ({
})
=>
{
await
connectToDatabase
();
const
modelItem
=
modelList
.
find
((
item
)
=>
item
.
model
===
modelName
);
if
(
!
modelItem
)
return
;
let
billId
;
try
{
await
connectToDatabase
();
const
modelItem
=
modelList
.
find
((
item
)
=>
item
.
model
===
modelName
);
if
(
!
modelItem
)
return
;
...
...
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