From 16f91b53b5c09c31df0ae8785142cd8e8ffc4226 Mon Sep 17 00:00:00 2001 From: josc146 Date: Mon, 5 Jun 2023 10:43:56 +0800 Subject: [PATCH] improve compatibility --- src/services/apis/custom-api.mjs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/services/apis/custom-api.mjs b/src/services/apis/custom-api.mjs index d6427dc..22952cb 100644 --- a/src/services/apis/custom-api.mjs +++ b/src/services/apis/custom-api.mjs @@ -60,13 +60,15 @@ export async function generateAnswersWithCustomApi(port, question, session, apiK console.debug('json error', error) return } - - answer += - data.choices[0]?.delta?.content || - data.choices[0]?.message?.content || - data.choices[0]?.text || - data.response || - '' + + if (data.response) + answer = data.response + else + answer += + data.choices[0]?.delta?.content || + data.choices[0]?.message?.content || + data.choices[0]?.text || + '' port.postMessage({ answer: answer, done: false, session: null }) }, async onStart() {},