Skip to content

Commit

Permalink
feat: more err log
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangsx committed May 7, 2023
1 parent 08db26b commit 5d38348
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) => {
Expand All @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion model/forefront/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5d38348

Please sign in to comment.