Skip to content

Commit a3fc686

Browse files
committed
feat: error handling update
1 parent 3f64224 commit a3fc686

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

src/services/ai.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,6 @@ const CheckDiscussion = 'Check if the question is related to discussion.';
1313
export class AiService {
1414
constructor(private knex: Knex, private bot: TelegramBot, private mcpClient: Client) { }
1515

16-
private sessionExists = async (session: string): Promise<boolean> => {
17-
const response = await this.mcpClient.callTool({
18-
name: "session_exists",
19-
arguments: { session }
20-
});
21-
22-
return (response.content as any)[0].text !== 'false';
23-
};
24-
25-
private createMcpSession = async (session: string): Promise<void> => {
26-
const exists = await this.sessionExists(session);
27-
if (exists) return;
28-
await this.mcpClient.callTool({
29-
name: "create_session",
30-
arguments: {
31-
session,
32-
flexible: true,
33-
}
34-
});
35-
}
36-
3716
private clearMcpSession = async (session: string): Promise<void> => {
3817
await this.mcpClient.callTool({
3918
name: "clear_session",
@@ -110,7 +89,8 @@ export class AiService {
11089
if (reply === 'yes' || reply === 'no') {
11190
return reply === 'yes';
11291
} else {
113-
throw new Error(`Unexpected response from Gemini (boolean): ${reply}. Expected 'yes' or 'no'.`);
92+
console.error(`Unexpected response from Gemini (boolean): ${reply}. Expected 'yes' or 'no'.`);
93+
return true; // Default to true if unexpected response
11494
}
11595
};
11696

0 commit comments

Comments
 (0)