feat: more err log

このコミットが含まれているのは:
xiang 2023-05-07 20:20:27 +08:00
コミット 5d38348833
2個のファイルの変更6行の追加5行の削除

ファイルの表示

@ -9,8 +9,9 @@ const errorHandler = async (ctx: Context, next: Next) => {
try {
await next();
} catch (err:any) {
ctx.response.status = err.status || 500;
ctx.response.body = err;
console.error(err);
ctx.body = JSON.stringify(err);
ctx.res.end();
}
};
app.use(errorHandler);
@ -34,7 +35,7 @@ router.get('/ask', async (ctx) => {
return;
}
const res = await chat.ask({prompt: prompt as string, options});
ctx.body = res.text;
ctx.body = res?.text;
});
router.get('/ask/stream', async (ctx) => {
@ -54,7 +55,7 @@ router.get('/ask/stream', async (ctx) => {
"Connection": "keep-alive",
});
const res = await chat.askStream({prompt: prompt as string, options});
ctx.body = res.text;
ctx.body = res?.text;
})
app.use(router.routes());

ファイルの表示

@ -149,7 +149,7 @@ export class Forefront extends Chat {
return;
}
const [{delta: {content}}] = data.choices;
cb(null, content);
cb(null, content||'');
}))
return {text: stream};
} catch (e: any) {