diff --git a/apps/bot/src/index.ts b/apps/bot/src/index.ts index bca1d4b..5ae1326 100644 --- a/apps/bot/src/index.ts +++ b/apps/bot/src/index.ts @@ -157,7 +157,8 @@ const conversationalAssistant = createOpenAiChatAssistant( const topicProcessor = createTopicProcessor( runtime.openaiApiKey, runtime.topicProcessorModel, - runtime.topicProcessorTimeoutMs + runtime.topicProcessorTimeoutMs, + getLogger('topic-processor') ) const householdContextCache = new HouseholdContextCache() const anonymousFeedbackRepositoryClients = new Map< diff --git a/apps/bot/src/topic-processor.ts b/apps/bot/src/topic-processor.ts index d3b491c..3b2df9f 100644 --- a/apps/bot/src/topic-processor.ts +++ b/apps/bot/src/topic-processor.ts @@ -245,7 +245,8 @@ function buildRecentMessagesSection(input: TopicProcessorInput): string | null { export function createTopicProcessor( apiKey: string | undefined, model: string, - timeoutMs: number + timeoutMs: number, + logger?: { error: (obj: unknown, msg?: string) => void } ): TopicProcessor | undefined { if (!apiKey) { return undefined @@ -506,7 +507,8 @@ If user dismisses ("не, забей", "cancel"), use dismiss_workflow.` default: return { route: 'silent', reason: 'unknown_route' } } - } catch { + } catch (error) { + logger?.error({ event: 'topic_processor.failed', error }, 'Topic processor failed') return null } finally { clearTimeout(timeout)