Skip to content

Commit c792148

Browse files
author
Kerwin
committed
fix: access token error
1 parent f0f1cfb commit c792148

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

service/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,14 @@ router.post('/chat-process', [auth, limiter], async (req, res) => {
304304
detail: {
305305
choices: [
306306
{
307-
finish_reason: chat.detail.choices[0].finish_reason,
307+
finish_reason: undefined,
308308
},
309309
],
310310
},
311311
}
312+
if (chat.detail && chat.detail.choices.length > 0)
313+
chuck.detail.choices[0].finish_reason = chat.detail.choices[0].finish_reason
314+
312315
res.write(firstChunk ? JSON.stringify(chuck) : `\n${JSON.stringify(chuck)}`)
313316
firstChunk = false
314317
},

src/views/chat/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ async function onConversation() {
159159
},
160160
)
161161
162-
if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
162+
if (openLongReply && data.detail && data.detail.choices.length > 0 && data.detail.choices[0].finish_reason === 'length') {
163163
options.parentMessageId = data.id
164164
lastText = data.text
165165
message = ''
@@ -302,7 +302,7 @@ async function onRegenerate(index: number) {
302302
},
303303
)
304304
305-
if (openLongReply && data.detail.choices[0].finish_reason === 'length') {
305+
if (openLongReply && data.detail && data.detail.choices.length > 0 && data.detail.choices[0].finish_reason === 'length') {
306306
options.parentMessageId = data.id
307307
lastText = data.text
308308
message = ''

0 commit comments

Comments
 (0)