feat(custom_providers_support): support custom OpenAI/Anthropic-compatible LLM endpoints - #73
feat(custom_providers_support): support custom OpenAI/Anthropic-compatible LLM endpoints#73erbanku wants to merge 2 commits into
Conversation
…tible LLM endpoints Add configurable provider, base URL, and model resolution for semantic search. Enable OpenAI-compatible, Anthropic-compatible, local, and enterprise-hosted endpoints via environment variables.
|
I added myself to the author field in I have published it here: https://www.npmjs.com/package/@erbanku/lat.md |
There was a problem hiding this comment.
Pull request overview
This PR extends lat search/lat expand semantic search configuration to support custom OpenAI-compatible and Anthropic-compatible embedding endpoints (base URL, provider header format, model override), and adds runtime dimension resolution so the vectors DB schema can adapt to non-default embedding models.
Changes:
- Add env/config resolvers for
LAT_LLM_BASE_URL,LAT_LLM_PROVIDER,LAT_LLM_MODEL, andLAT_LLM_ANTHROPIC_VERSION, and wire them into provider detection. - Introduce
resolveSchema()to probe/cached embedding dimensions and trigger automatic DB rebuild when provider/model changes. - Expand tests and documentation to cover custom endpoints and dimension resolution behavior.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/search.test.ts | Adds unit tests for custom endpoint provider detection and model override dimension behavior. |
| tests/schema.test.ts | Adds tests for schema dimension probing + caching using a local embeddings stub server. |
| tests/config.test.ts | Adds tests for env/config resolution of custom endpoint settings and bundling into provider options. |
| templates/cursor-rules.md | Updates guidance for semantic search setup to mention custom endpoints. |
| templates/AGENTS.md | Updates agent guidance for semantic search setup to mention custom endpoints. |
| src/search/schema.ts | New schema resolution layer that probes/caches embedding dimensions and detects provider/model changes. |
| src/search/provider.ts | Adds ProviderOptions, custom base URL support, Anthropic-compatible header mode, and model overrides that clear static dims. |
| src/config.ts | Adds config fields + env/config resolution functions for custom endpoint/provider/model settings. |
| src/cli/search.ts | Uses provider options + schema resolution; drops/rebuilds DB table when provider signature changes; improves CLI error handling paths. |
| src/cli/init.ts | Adds CLI init messaging describing advanced custom-endpoint environment variables. |
| src/cli/index.ts | Enhances lat config output to show resolved LLM settings. |
| README.md | Documents custom endpoint configuration and new env vars/config fields. |
| package.json | Updates package metadata (name/author/repo/homepage/publishConfig) alongside the feature changes. |
| lat.md/tests/search.md | Documents new/expanded tests for configuration, provider detection, and dimension resolution. |
| lat.md/cli.md | Documents new config fields, provider detection order, and the dimension resolution mechanism. |
| CLAUDE.md | Updates agent instructions for semantic search setup to mention custom endpoints. |
| AGENTS.md | Updates agent instructions for semantic search setup to mention custom endpoints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let dimensions = provider.dimensions; | ||
| if (dimensions === undefined && !configChanged) { | ||
| const cached = await getMeta(db, DIMENSIONS_META_KEY); | ||
| if (cached) dimensions = parseInt(cached, 10); | ||
| } |
| try { | ||
| await runIndex(ctx.latDir, key, progress); | ||
| } catch (err) { | ||
| return { output: (err as Error).message, isError: true }; | ||
| } |
| let result: SearchResult; | ||
| try { | ||
| result = await runSearch(ctx.latDir, query, key, opts.limit, progress); | ||
| } catch (err) { | ||
| return { output: (err as Error).message, isError: true }; | ||
| } |
| "name": "@erbanku/lat.md", | ||
| "version": "0.11.2", | ||
| "description": "A knowledge graph for your codebase, written in markdown", | ||
| "type": "module", | ||
| "packageManager": "pnpm@10.30.2", | ||
| "license": "MIT", | ||
| "author": "Yury Selivanov", | ||
| "author": "Erban Ku", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/1st1/lat.md.git" | ||
| "url": "git+https://github.com/erbanku/lat.md.git" | ||
| }, | ||
| "homepage": "https://github.com/erbanku/lat.md", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@erbanku I've just implemented local embeddings support as native a default option for lat.
Anthropic doesn't seem to have embeddings models/api, what does anthropic-compatible mean in this context? |
|
Anthropic-compatible here means the API format (headers and request shape), not Anthropic’s own models. Some third-party providers expose embeddings behind that Anthropic-style API, which is what I wanted to support. Anthropic itself doesn’t have an embeddings API, as you said. Happy to clarify that in the docs if the naming is confusing. |
Add configurable provider, base URL, and model resolution for semantic search.
Enable OpenAI-compatible, Anthropic-compatible, local, and enterprise-hosted endpoints via environment variables.
Closes #72