From 0d7cfe8061c7add1d97b3acc386e85c3be6a6c16 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Tue, 15 Apr 2025 17:44:29 +0000 Subject: [PATCH] fix hardcoded values part 2 --- src/services/llm/pipeline/chat_pipeline.ts | 7 +++--- .../pipeline/stages/model_selection_stage.ts | 24 ++++++++++++------- .../semantic_context_extraction_stage.ts | 3 ++- .../pipeline/stages/vector_search_stage.ts | 5 ++-- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/services/llm/pipeline/chat_pipeline.ts b/src/services/llm/pipeline/chat_pipeline.ts index 12be376a0..0136be93c 100644 --- a/src/services/llm/pipeline/chat_pipeline.ts +++ b/src/services/llm/pipeline/chat_pipeline.ts @@ -13,6 +13,7 @@ import toolRegistry from '../tools/tool_registry.js'; import toolInitializer from '../tools/tool_initializer.js'; import log from '../../log.js'; import type { LLMServiceInterface } from '../interfaces/agent_tool_interfaces.js'; +import { SEARCH_CONSTANTS } from '../constants/search_constants.js'; /** * Pipeline for managing the entire chat flow @@ -56,7 +57,7 @@ export class ChatPipeline { this.config = { enableStreaming: true, enableMetrics: true, - maxToolCallIterations: 5, + maxToolCallIterations: SEARCH_CONSTANTS.TOOL_EXECUTION.MAX_TOOL_CALL_ITERATIONS, ...config }; @@ -194,9 +195,9 @@ export class ChatPipeline { query: userQuery, noteId: input.noteId || 'global', options: { - maxResults: 5, // Can be adjusted + maxResults: SEARCH_CONSTANTS.CONTEXT.MAX_SIMILAR_NOTES, useEnhancedQueries: true, - threshold: 0.6, + threshold: SEARCH_CONSTANTS.VECTOR_SEARCH.DEFAULT_THRESHOLD, llmService: llmService || undefined } }); diff --git a/src/services/llm/pipeline/stages/model_selection_stage.ts b/src/services/llm/pipeline/stages/model_selection_stage.ts index 5245e3a4c..35634c210 100644 --- a/src/services/llm/pipeline/stages/model_selection_stage.ts +++ b/src/services/llm/pipeline/stages/model_selection_stage.ts @@ -5,6 +5,7 @@ import type { ModelMetadata } from '../../providers/provider_options.js'; import log from '../../../log.js'; import options from '../../../options.js'; import aiServiceManager from '../../ai_service_manager.js'; +import { SEARCH_CONSTANTS, MODEL_CAPABILITIES } from "../../constants/search_constants.js"; /** * Pipeline stage for selecting the appropriate LLM model */ @@ -28,7 +29,7 @@ export class ModelSelectionStage extends BasePipelineStage 5000) { + if (contentLength && contentLength > SEARCH_CONSTANTS.CONTEXT.CONTENT_LENGTH.MEDIUM_THRESHOLD) { // For large content, favor more powerful models - queryComplexity = contentLength > 10000 ? 'high' : 'medium'; + queryComplexity = contentLength > SEARCH_CONSTANTS.CONTEXT.CONTENT_LENGTH.HIGH_THRESHOLD ? 'high' : 'medium'; } // Set the model and add provider metadata @@ -256,7 +257,7 @@ export class ModelSelectionStage extends BasePipelineStage