Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/cli/qmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import {
type ReindexResult,
type ChunkStrategy,
} from "../store.js";
import { disposeDefaultLlamaCpp, getDefaultLlamaCpp, setDefaultLlamaCpp, LlamaCpp, withLLMSession, pullModels, DEFAULT_EMBED_MODEL_URI, DEFAULT_GENERATE_MODEL_URI, DEFAULT_RERANK_MODEL_URI, DEFAULT_MODEL_CACHE_DIR } from "../llm.js";
import { disposeDefaultLlamaCpp, getDefaultLlamaCpp, setDefaultLlamaCpp, LlamaCpp, withLLMSession, pullModels, DEFAULT_EMBED_MODEL_URI, DEFAULT_MODEL_CACHE_DIR } from "../llm.js";
import {
formatSearchResults,
formatDocuments,
Expand Down Expand Up @@ -462,9 +462,10 @@ async function showStatus(): Promise<void> {
return match ? `https://huggingface.co/${match[1]}` : uri;
};
console.log(`\n${c.bold}Models${c.reset}`);
console.log(` Embedding: ${hfLink(DEFAULT_EMBED_MODEL_URI)}`);
console.log(` Reranking: ${hfLink(DEFAULT_RERANK_MODEL_URI)}`);
console.log(` Generation: ${hfLink(DEFAULT_GENERATE_MODEL_URI)}`);
const llm = getDefaultLlamaCpp();
console.log(` Embedding: ${hfLink(llm.embedModelName)}`);
console.log(` Reranking: ${hfLink(llm.rerankModelName)}`);
console.log(` Generation: ${hfLink(llm.generateModelName)}`);
}

// Device / GPU info
Expand Down Expand Up @@ -3107,7 +3108,7 @@ if (isMain) {
const maxDocsPerBatch = parseEmbedBatchOption("maxDocsPerBatch", cli.values["max-docs-per-batch"]);
const maxBatchMb = parseEmbedBatchOption("maxBatchBytes", cli.values["max-batch-mb"]);
const embedChunkStrategy = parseChunkStrategy(cli.values["chunk-strategy"]);
await vectorIndex(DEFAULT_EMBED_MODEL_URI, !!cli.values.force, {
await vectorIndex(getDefaultLlamaCpp().embedModelName, !!cli.values.force, {
maxDocsPerBatch,
maxBatchBytes: maxBatchMb === undefined ? undefined : maxBatchMb * 1024 * 1024,
chunkStrategy: embedChunkStrategy,
Expand All @@ -3120,10 +3121,11 @@ if (isMain) {

case "pull": {
const refresh = cli.values.refresh === undefined ? false : Boolean(cli.values.refresh);
const llm = getDefaultLlamaCpp();
const models = [
DEFAULT_EMBED_MODEL_URI,
DEFAULT_GENERATE_MODEL_URI,
DEFAULT_RERANK_MODEL_URI,
llm.embedModelName,
llm.generateModelName,
llm.rerankModelName,
];
console.log(`${c.bold}Pulling models${c.reset}`);
const results = await pullModels(models, {
Expand Down
8 changes: 8 additions & 0 deletions src/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,14 @@ export class LlamaCpp implements LLM {
return this.embedModelUri;
}

get generateModelName(): string {
return this.generateModelUri;
}

get rerankModelName(): string {
return this.rerankModelUri;
}

/**
* Reset the inactivity timer. Called after each model operation.
* When timer fires, models are unloaded to free memory (if no active sessions).
Expand Down