Removed callbacks

This commit is contained in:
uxname committed 2025-05-25 17:51:41 +03:00
1 parent 0591fb80a4
commit 52a78c7119
1 file changed
+3 -18
+3 -18
View File
@@ -7,14 +7,6 @@ export class TelegramBot {
private pipelineExecutor: PipelineExecutor; private pipelineExecutor: PipelineExecutor;
private activePipelines: Map<number, { pipeline: Pipeline; chatId: number }> = private activePipelines: Map<number, { pipeline: Pipeline; chatId: number }> =
new Map(); new Map();
private stepCallbacks: Map<
string,
(
stepName: string,
status: 'started' | 'completed',
result?: string,
) => Promise<void>
> = new Map();
constructor(token: string, mcpServerUrl: string) { constructor(token: string, mcpServerUrl: string) {
this.bot = new Telegraf(token); this.bot = new Telegraf(token);
@@ -110,9 +102,6 @@ export class TelegramBot {
}, },
], ],
}; };
const pipelineId = `pipeline_${Date.now()}_${chatId}`;
const stepCallback = this.setupStepCallback(pipelineId, chatId);
this.stepCallbacks.set(pipelineId, stepCallback);
this.activePipelines.set(chatId, { pipeline: userPipeline, chatId }); this.activePipelines.set(chatId, { pipeline: userPipeline, chatId });
await ctx.sendChatAction('typing'); await ctx.sendChatAction('typing');
@@ -123,20 +112,16 @@ export class TelegramBot {
variables: {}, variables: {},
systemPrompts: [], systemPrompts: [],
openAIApiKey: process.env.OPENAI_API_KEY || '', openAIApiKey: process.env.OPENAI_API_KEY || '',
onStepStart: async (stepName) => { onStepStart: async (_stepName) => {
await stepCallback(stepName, 'started');
await ctx.sendChatAction('typing'); await ctx.sendChatAction('typing');
}, },
onStepComplete: async (stepName, result, isLastStep) => { onStepComplete: async (_stepName, _result, isLastStep) => {
// Skip the completion notification for the last step as it will be sent as the final response
if (!isLastStep) { if (!isLastStep) {
await stepCallback(stepName, 'completed', result); await ctx.sendChatAction('typing');
} }
}, },
}); });
this.stepCallbacks.delete(pipelineId);
const lastResult = results[results.length - 1]; const lastResult = results[results.length - 1];
if (lastResult) { if (lastResult) {
// remove ``` in start and ``` in end // remove ``` in start and ``` in end