Skip to content

fix: skip API key check for local providers and fix /v1 endpoint suffix#5

Open
bluzername wants to merge 1 commit into
MadAppGang:mainfrom
bluzername:fix/skip-api-key-for-local-providers
Open

fix: skip API key check for local providers and fix /v1 endpoint suffix#5
bluzername wants to merge 1 commit into
MadAppGang:mainfrom
bluzername:fix/skip-api-key-for-local-providers

Conversation

@bluzername

Copy link
Copy Markdown

Problem

Two bugs from issue #4 when using mnemex with Ollama or other local embedding providers:

Bug 1: mnemex index requires OpenRouter API key even when using Ollama/local provider. Running mnemex index after configuring Ollama gives:

Error: OpenRouter API key not configured.
Run 'mnemex init' to set up, or set OPENROUTER_API_KEY.

This makes no sense because I configured Ollama as my embedding provider, not OpenRouter.

Bug 2: The init wizard saves localEndpoint without /v1 suffix, but the embeddings client sends requests to {localEndpoint}/embeddings which gives 404. The LLM endpoint is correctly set to http://localhost:11434/v1 by the same wizard - inconsistent behavior.

What I changed

Bug 1 fix - src/config.ts:

  • Added isLocalEmbeddingProvider(projectPath) function that checks if the project config has embeddingProvider set to ollama, lmstudio, or local
  • Uses the existing loadProjectConfig() to read the setting

Bug 1 fix - src/cli.ts:

  • Imported isLocalEmbeddingProvider
  • Updated the API key check in index command (line ~725): added && !isLocalEmbeddingProvider(projectPath) so local providers skip the check
  • Updated the API key check in search command (line ~1509): same fix
  • Left the benchmark command check unchanged (benchmarks are dev tools that may need cloud APIs regardless)

Bug 2 fix - src/cli.ts:

  • When saving config for local provider, the endpoint now gets /v1 appended if not already present: embeddingEndpoint.endsWith("/v1") ? embeddingEndpoint : embeddingEndpoint + "/v1"
  • This matches how lmstudio endpoint already defaults to http://localhost:1234/v1

Not addressed

Bug 3 from issue #4 (hardcoded wasm path for global install) - this one needs deeper investigation into the tree-sitter wasm resolution logic which I didnt want to mix into this PR.

Closes #4 (bugs 1 and 2)

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.

Multiple bugs when using local/Ollama providers (API key required, missing /v1, broken global install)

1 participant