Skip to content

Commit 33d6254

Browse files
committed
Improve logging
1 parent d6312ee commit 33d6254

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

package-lock.json

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,23 @@ bot.on("message", async (ctx) => {
7878
}
7979

8080
console.log("Input: ", text);
81+
8182
await ctx.sendChatAction("typing");
8283
try {
8384
const response = await model.call(text);
8485

8586
await ctx.reply(response);
8687
} catch (error) {
8788
console.log(error);
89+
90+
const message = JSON.stringify(
91+
(error as any)?.response?.data?.error ?? "Unable to extract error"
92+
);
93+
94+
console.log({ message });
95+
8896
await ctx.reply(
89-
"Whoops! There was an error while talking to OpenAI. See logs for details."
97+
"Whoops! There was an error while talking to OpenAI. Error: " + message
9098
);
9199
}
92100
});

src/models/chatWithTools.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class Model {
5050

5151
const response = await this.executor!.call({ input });
5252

53-
console.log(response);
53+
console.log("Model response: " + response);
5454

5555
return response.output;
5656
}

0 commit comments

Comments
 (0)