feat: more err log
このコミットが含まれているのは:
コミット
5d38348833
9
index.ts
9
index.ts
|
@ -9,8 +9,9 @@ const errorHandler = async (ctx: Context, next: Next) => {
|
||||||
try {
|
try {
|
||||||
await next();
|
await next();
|
||||||
} catch (err:any) {
|
} catch (err:any) {
|
||||||
ctx.response.status = err.status || 500;
|
console.error(err);
|
||||||
ctx.response.body = err;
|
ctx.body = JSON.stringify(err);
|
||||||
|
ctx.res.end();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
app.use(errorHandler);
|
app.use(errorHandler);
|
||||||
|
@ -34,7 +35,7 @@ router.get('/ask', async (ctx) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const res = await chat.ask({prompt: prompt as string, options});
|
const res = await chat.ask({prompt: prompt as string, options});
|
||||||
ctx.body = res.text;
|
ctx.body = res?.text;
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/ask/stream', async (ctx) => {
|
router.get('/ask/stream', async (ctx) => {
|
||||||
|
@ -54,7 +55,7 @@ router.get('/ask/stream', async (ctx) => {
|
||||||
"Connection": "keep-alive",
|
"Connection": "keep-alive",
|
||||||
});
|
});
|
||||||
const res = await chat.askStream({prompt: prompt as string, options});
|
const res = await chat.askStream({prompt: prompt as string, options});
|
||||||
ctx.body = res.text;
|
ctx.body = res?.text;
|
||||||
})
|
})
|
||||||
|
|
||||||
app.use(router.routes());
|
app.use(router.routes());
|
||||||
|
|
|
@ -149,7 +149,7 @@ export class Forefront extends Chat {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const [{delta: {content}}] = data.choices;
|
const [{delta: {content}}] = data.choices;
|
||||||
cb(null, content);
|
cb(null, content||'');
|
||||||
}))
|
}))
|
||||||
return {text: stream};
|
return {text: stream};
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
|
読み込み中…
新しいイシューから参照