Skip to content

fix(llm): add type cast for autoAttempt build option#333

Open
JasonOA888 wants to merge 2 commits intotobi:mainfrom
JasonOA888:fix/typescript-autoattempt
Open

fix(llm): add type cast for autoAttempt build option#333
JasonOA888 wants to merge 2 commits intotobi:mainfrom
JasonOA888:fix/typescript-autoattempt

Conversation

@JasonOA888
Copy link

Problem

v1.1.5 fails to build with TypeScript compilation error:

src/llm.ts(548,27): error TS2769: No overload matches this call.
  Type autoAttempt is not assignable to type auto | never | forceRebuild | try | undefined

Root Cause

The "autoAttempt" value is valid in node-llama-cpp runtime but not included in TypeScript type definitions.

Solution

Cast to any to bypass type check while preserving runtime behavior.

Alternative Considered

Could use "try" instead, but "autoAttempt" has better behavior (attempts build without forcing).

Fixes #317

Previously, 'qmd embed' always displayed 'Model: embeddinggemma'
even when using a custom model via QMD_EMBED_MODEL env var.

Root cause: store.ts exports DEFAULT_EMBED_MODEL as a hardcoded
display label, while llm.ts uses DEFAULT_EMBED_MODEL_URI for the
actual model path. qmd.ts was using the wrong constant.

Changes:
- Add extractModelDisplayName() helper to extract readable name from URI
- Change vectorIndex(), vectorSearch(), querySearch() to use
  DEFAULT_EMBED_MODEL_URI instead of store's DEFAULT_EMBED_MODEL
- Apply extractModelDisplayName() when printing the model name

Now correctly shows:
- 'embeddinggemma-300M-Q8_0' for default model
- 'Qwen3-Embedding-0.6B-Q8_0' for custom models

Fixes tobi#328
The 'autoAttempt' value is valid in node-llama-cpp runtime but not
included in TypeScript types. This causes build failures:

  src/llm.ts(548,27): error TS2769: No overload matches this call.
  Type 'autoAttempt' is not assignable to type
  'auto | never | forceRebuild | try | undefined'

Fix: Cast to 'any' to bypass type check while preserving runtime behavior.

Fixes tobi#317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v1.1.5 Build Error - TypeScript compilation failed

1 participant