diff --git a/packages/learning/src/few-shot-curator/index.ts b/packages/learning/src/few-shot-curator/index.ts index e873e85..6a7f9a4 100644 --- a/packages/learning/src/few-shot-curator/index.ts +++ b/packages/learning/src/few-shot-curator/index.ts @@ -9,16 +9,19 @@ */ import { readFileSync, writeFileSync, readdirSync } from 'fs'; -import { join } from 'path'; +import { fileURLToPath } from 'url'; +import { join, resolve } from 'path'; import yaml from 'js-yaml'; import { query, withTransaction } from '../db/client.js'; import { logger } from '../observability/logger.js'; // ─── Constants ────────────────────────────────────────────────────────────── +const _dir = fileURLToPath(new URL('.', import.meta.url)); +const _defaultTemplatesDir = resolve(join(_dir, '..', '..', '..', 'gateway', 'prompts', 'templates')); + const TEMPLATES_DIR = - process.env['TEMPLATES_DIR'] ?? - '/Users/renefichtmueller/Desktop/Claude Code/llm-gateway/packages/gateway/prompts/templates'; + process.env['TEMPLATES_DIR'] ?? _defaultTemplatesDir; const MIN_CONFIDENCE = 9.0; const SIMILARITY_THRESHOLD = 0.7; diff --git a/packages/learning/src/prompt-optimizer/index.ts b/packages/learning/src/prompt-optimizer/index.ts index 0d9558d..71f0fbe 100644 --- a/packages/learning/src/prompt-optimizer/index.ts +++ b/packages/learning/src/prompt-optimizer/index.ts @@ -13,7 +13,8 @@ */ import { readFileSync, writeFileSync } from 'fs'; -import { join } from 'path'; +import { fileURLToPath } from 'url'; +import { join, resolve } from 'path'; import yaml from 'js-yaml'; import { query, withTransaction } from '../db/client.js'; import { callGateway } from '../gateway-client.js'; @@ -22,9 +23,11 @@ import { bumpMinorVersion } from '../few-shot-curator/index.js'; // ─── Constants ────────────────────────────────────────────────────────────── +const _dir = fileURLToPath(new URL('.', import.meta.url)); +const _defaultTemplatesDir = resolve(join(_dir, '..', '..', '..', 'gateway', 'prompts', 'templates')); + const TEMPLATES_DIR = - process.env['TEMPLATES_DIR'] ?? - '/Users/renefichtmueller/Desktop/Claude Code/llm-gateway/packages/gateway/prompts/templates'; + process.env['TEMPLATES_DIR'] ?? _defaultTemplatesDir; // Task types that MUST have human review before prompt updates go live const SENSITIVE_TASK_TYPES = new Set([ diff --git a/packages/learning/src/routing-optimizer/index.ts b/packages/learning/src/routing-optimizer/index.ts index 8463a56..8d6b02b 100644 --- a/packages/learning/src/routing-optimizer/index.ts +++ b/packages/learning/src/routing-optimizer/index.ts @@ -10,6 +10,8 @@ */ import { readFileSync, writeFileSync } from 'fs'; +import { fileURLToPath } from 'url'; +import { join, resolve } from 'path'; import yaml from 'js-yaml'; import { query, withTransaction } from '../db/client.js'; import { postInternal } from '../gateway-client.js'; @@ -17,9 +19,12 @@ import { logger } from '../observability/logger.js'; // ─── Constants ────────────────────────────────────────────────────────────── +// Resolve path relative to this file: packages/learning/src/routing-optimizer/ → packages/gateway/src/config/ +const _dir = fileURLToPath(new URL('.', import.meta.url)); +const _defaultRoutingRulesPath = resolve(join(_dir, '..', '..', '..', 'gateway', 'src', 'config', 'routing-rules.yaml')); + const ROUTING_RULES_PATH = - process.env['ROUTING_RULES_PATH'] ?? - '/Users/renefichtmueller/Desktop/Claude Code/llm-gateway/packages/gateway/src/config/routing-rules.yaml'; + process.env['ROUTING_RULES_PATH'] ?? _defaultRoutingRulesPath; const MIN_CONFIDENCE_DELTA = 1.0; const MIN_LATENCY_IMPROVEMENT_PCT = 30;