Skip to content

Commit 77ffffc

Browse files
fix: make embed command respect config embeddings.model
The CLI embed command hardcoded 'minilm' as the default model via Commander, ignoring .codegraphrc.json config entirely. Now the embed command reads config.embeddings.model as the default when no -m flag is passed. Also fixes DEFAULTS.embeddings.model from 'nomic-v1.5' to 'minilm' to match the actual fallback used by the embedder, and updates the models command to show the configured default.
1 parent c21c387 commit 77ffffc

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/cli.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,13 @@ program
423423
.command('models')
424424
.description('List available embedding models')
425425
.action(() => {
426+
const defaultModel = config.embeddings?.model || 'minilm';
426427
console.log('\nAvailable embedding models:\n');
427-
for (const [key, config] of Object.entries(MODELS)) {
428-
const def = key === 'minilm' ? ' (default)' : '';
429-
const ctx = config.contextWindow ? `${config.contextWindow} ctx` : '';
428+
for (const [key, cfg] of Object.entries(MODELS)) {
429+
const def = key === defaultModel ? ' (default)' : '';
430+
const ctx = cfg.contextWindow ? `${cfg.contextWindow} ctx` : '';
430431
console.log(
431-
` ${key.padEnd(12)} ${String(config.dim).padStart(4)}d ${ctx.padEnd(9)} ${config.desc}${def}`,
432+
` ${key.padEnd(12)} ${String(cfg.dim).padStart(4)}d ${ctx.padEnd(9)} ${cfg.desc}${def}`,
432433
);
433434
}
434435
console.log('\nUsage: codegraph embed --model <name> --strategy <structured|source>');
@@ -442,8 +443,7 @@ program
442443
)
443444
.option(
444445
'-m, --model <name>',
445-
'Embedding model: minilm (default), jina-small, jina-base, jina-code, nomic, nomic-v1.5, bge-large. Run `codegraph models` for details',
446-
'minilm',
446+
'Embedding model (default from config or minilm). Run `codegraph models` for details',
447447
)
448448
.option(
449449
'-s, --strategy <name>',
@@ -458,7 +458,8 @@ program
458458
process.exit(1);
459459
}
460460
const root = path.resolve(dir || '.');
461-
await buildEmbeddings(root, opts.model, undefined, { strategy: opts.strategy });
461+
const model = opts.model || config.embeddings?.model || 'minilm';
462+
await buildEmbeddings(root, model, undefined, { strategy: opts.strategy });
462463
});
463464

464465
program

src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const DEFAULTS = {
2020
defaultLimit: 20,
2121
excludeTests: false,
2222
},
23-
embeddings: { model: 'nomic-v1.5', llmProvider: null },
23+
embeddings: { model: 'minilm', llmProvider: null },
2424
llm: { provider: null, model: null, baseUrl: null, apiKey: null, apiKeyCommand: null },
2525
search: { defaultMinScore: 0.2, rrfK: 60, topK: 15 },
2626
ci: { failOnCycles: false, impactThreshold: null },

tests/unit/config.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('DEFAULTS', () => {
5555
});
5656

5757
it('has embeddings defaults', () => {
58-
expect(DEFAULTS.embeddings).toEqual({ model: 'nomic-v1.5', llmProvider: null });
58+
expect(DEFAULTS.embeddings).toEqual({ model: 'minilm', llmProvider: null });
5959
});
6060

6161
it('has llm defaults', () => {

0 commit comments

Comments
 (0)