Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/guide/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ src/
│ ├── embedding.ts # EmbeddingProvider interface
│ ├── index.ts # createEmbeddingProvider() from config
│ ├── dimensions.ts # vector sizes of known models
│ ├── local.ts # all-MiniLM-L6-v2 on onnxruntime-web (WebAssembly)
│ ├── local.ts # local models (all-MiniLM-L6-v2, bge) on onnxruntime-web (WebAssembly)
│ ├── ollama.ts # Ollama HTTP API
│ └── openai.ts # OpenAI embeddings API
├── registry/ # git pack registries: config, git, sync, search, resolve, publish, checksum
Expand Down
24 changes: 18 additions & 6 deletions docs/guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ Earlier versions of the SDK stored data in `~/.libscope/libscope.db`. If that fi

Embeddings turn text into vectors for semantic search. LibScope supports three providers:

| Provider | Default | Requires | Notes |
| -------- | ------- | ---------------------- | --------------------------------------------- |
| `local` | ✅ | Nothing | all-MiniLM-L6-v2, ~90MB download on first use |
| `ollama` | | Ollama running locally | Uses nomic-embed-text by default |
| `openai` | | API key | Uses text-embedding-3-small by default |
| Provider | Default | Requires | Notes |
| -------- | ------- | ---------------------- | ------------------------------------------------------------- |
| `local` | ✅ | Nothing | Uses all-MiniLM-L6-v2 by default, ~90MB download on first use |
| `ollama` | | Ollama running locally | Uses nomic-embed-text by default |
| `openai` | | API key | Uses text-embedding-3-small by default |

The local provider works out of the box — no API keys, no external services. It runs the model in-process on the ONNX Runtime WebAssembly build (no native addon) and caches it in `~/.libscope/models`.

Expand All @@ -84,7 +84,19 @@ libscope config set embedding.provider openai
libscope config set openai.apiKey sk-... # or export OPENAI_API_KEY
```

`embedding.model` and `embedding.url` apply to the selected provider. The local provider always uses all-MiniLM-L6-v2 and ignores `embedding.model`.
`embedding.model` and `embedding.url` apply to the selected provider. For the local provider, `embedding.model` selects one of these models. Any other name is an error.

| `embedding.model` | Vector size | Max tokens | Download |
| ---------------------------- | ----------- | ---------- | -------- |
| `all-MiniLM-L6-v2` (default) | 384 | 256 | ~90MB |
| `bge-small-en-v1.5` | 384 | 512 | ~130MB |
| `bge-base-en-v1.5` | 768 | 512 | ~440MB |

```bash
libscope config set embedding.model bge-small-en-v1.5
```

Earlier versions ignored `embedding.model` (and `LIBSCOPE_EMBEDDING_MODEL`) for the local provider. A value left from another provider is now an error, and a bge name selects that model, so an existing index then needs a rebuild. To go back to the default, run `libscope config unset embedding.model`, or remove `LIBSCOPE_EMBEDDING_MODEL` or the key in the project `.libscope.json` if it is set there.

LibScope records the provider, model, and vector size that built the vector index. If you change the provider, the model, or `embedding.dimensions` after you index documents, LibScope stops with an error that names the old and the new model. To rebuild the vector index with the new model, run:

Expand Down
34 changes: 17 additions & 17 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ Every key `section.field` has the environment variable `LIBSCOPE_<SECTION>_<FIEL

<!-- generated:start config:keys -->

| Key | Type | Default | Environment variables | Secret | Description |
| ------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `embedding.provider` | `local` \| `ollama` \| `openai` | `local` | `LIBSCOPE_EMBEDDING_PROVIDER` | | Embedding provider. |
| `embedding.model` | string | ollama: nomic-embed-text; openai: text-embedding-3-small | `LIBSCOPE_EMBEDDING_MODEL` | | Embedding model. Ignored by the local provider (always sentence-transformers/all-MiniLM-L6-v2). |
| `embedding.url` | string | `http://localhost:11434` | `LIBSCOPE_EMBEDDING_URL` | | Server URL of the embedding provider. Used by the ollama provider. |
| `embedding.dimensions` | integer | size of the model | `LIBSCOPE_EMBEDDING_DIMENSIONS` | | Vector size, for models whose size is not built in. |
| `llm.provider` | `auto` \| `openai` \| `anthropic` \| `ollama` \| `passthrough` | `auto` | `LIBSCOPE_LLM_PROVIDER` | | LLM for "ask". "auto": passthrough under MCP, else openai if an OpenAI key is set, else anthropic if an Anthropic key is set, else ollama if llm.url is set or embedding.provider is ollama, else none. |
| `llm.model` | string | openai: gpt-4o-mini; anthropic: claude-3-5-haiku-20241022; ollama: llama3.2 | `LIBSCOPE_LLM_MODEL` | | LLM model. |
| `llm.url` | string | embedding.url, then `http://localhost:11434` | `LIBSCOPE_LLM_URL` | | Server URL of the LLM. Used by the ollama provider. |
| `openai.apiKey` | string | — | `LIBSCOPE_OPENAI_API_KEY`, `OPENAI_API_KEY` | yes | OpenAI API key (embeddings and LLM). |
| `anthropic.apiKey` | string | — | `LIBSCOPE_ANTHROPIC_API_KEY`, `ANTHROPIC_API_KEY` | yes | Anthropic API key (LLM). |
| `database.path` | string | `~/.libscope/workspaces/<workspace>/libscope.db` | `LIBSCOPE_DATABASE_PATH` | | SQLite database file. A leading ~ is expanded. Unset: the workspace database. |
| `indexing.maxDocumentSize` | integer | `104857600` | `LIBSCOPE_INDEXING_MAX_DOCUMENT_SIZE` | | Largest document to index, in bytes. |
| `indexing.allowPrivateUrls` | boolean | `false` | `LIBSCOPE_INDEXING_ALLOW_PRIVATE_URLS` | | Allow fetching URLs on private or local networks. |
| `indexing.allowSelfSignedCerts` | boolean | `false` | `LIBSCOPE_INDEXING_ALLOW_SELF_SIGNED_CERTS` | | Accept self-signed TLS certificates when fetching. |
| `logging.level` | `debug` \| `info` \| `warn` \| `error` \| `silent` | `info` | `LIBSCOPE_LOGGING_LEVEL` | | Log level. |
| `mcp.toolsets` | list of `core` \| `admin` \| `all` | `none` | `LIBSCOPE_MCP_TOOLSETS` | | Optional MCP toolsets (comma list). admin adds sync, install-pack, list-packs and reindex-documents; all enables every optional toolset. The core tools are always on. |
| Key | Type | Default | Environment variables | Secret | Description |
| ------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `embedding.provider` | `local` \| `ollama` \| `openai` | `local` | `LIBSCOPE_EMBEDDING_PROVIDER` | | Embedding provider. |
| `embedding.model` | string | local: all-MiniLM-L6-v2; ollama: nomic-embed-text; openai: text-embedding-3-small | `LIBSCOPE_EMBEDDING_MODEL` | | Embedding model. Models of the local provider: all-MiniLM-L6-v2, bge-small-en-v1.5, bge-base-en-v1.5. |
| `embedding.url` | string | `http://localhost:11434` | `LIBSCOPE_EMBEDDING_URL` | | Server URL of the embedding provider. Used by the ollama provider. |
| `embedding.dimensions` | integer | size of the model | `LIBSCOPE_EMBEDDING_DIMENSIONS` | | Vector size, for models whose size is not built in. |
| `llm.provider` | `auto` \| `openai` \| `anthropic` \| `ollama` \| `passthrough` | `auto` | `LIBSCOPE_LLM_PROVIDER` | | LLM for "ask". "auto": passthrough under MCP, else openai if an OpenAI key is set, else anthropic if an Anthropic key is set, else ollama if llm.url is set or embedding.provider is ollama, else none. |
| `llm.model` | string | openai: gpt-4o-mini; anthropic: claude-3-5-haiku-20241022; ollama: llama3.2 | `LIBSCOPE_LLM_MODEL` | | LLM model. |
| `llm.url` | string | embedding.url, then `http://localhost:11434` | `LIBSCOPE_LLM_URL` | | Server URL of the LLM. Used by the ollama provider. |
| `openai.apiKey` | string | — | `LIBSCOPE_OPENAI_API_KEY`, `OPENAI_API_KEY` | yes | OpenAI API key (embeddings and LLM). |
| `anthropic.apiKey` | string | — | `LIBSCOPE_ANTHROPIC_API_KEY`, `ANTHROPIC_API_KEY` | yes | Anthropic API key (LLM). |
| `database.path` | string | `~/.libscope/workspaces/<workspace>/libscope.db` | `LIBSCOPE_DATABASE_PATH` | | SQLite database file. A leading ~ is expanded. Unset: the workspace database. |
| `indexing.maxDocumentSize` | integer | `104857600` | `LIBSCOPE_INDEXING_MAX_DOCUMENT_SIZE` | | Largest document to index, in bytes. |
| `indexing.allowPrivateUrls` | boolean | `false` | `LIBSCOPE_INDEXING_ALLOW_PRIVATE_URLS` | | Allow fetching URLs on private or local networks. |
| `indexing.allowSelfSignedCerts` | boolean | `false` | `LIBSCOPE_INDEXING_ALLOW_SELF_SIGNED_CERTS` | | Accept self-signed TLS certificates when fetching. |
| `logging.level` | `debug` \| `info` \| `warn` \| `error` \| `silent` | `info` | `LIBSCOPE_LOGGING_LEVEL` | | Log level. |
| `mcp.toolsets` | list of `core` \| `admin` \| `all` | `none` | `LIBSCOPE_MCP_TOOLSETS` | | Optional MCP toolsets (comma list). admin adds sync, install-pack, list-packs and reindex-documents; all enables every optional toolset. The core tools are always on. |

<!-- generated:end config:keys -->

Expand Down
7 changes: 5 additions & 2 deletions src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* metadata. Secret keys are read only from env vars and ~/.libscope/secrets.json.
*/
import { z } from "zod";
import { DEFAULT_LOCAL_MODEL, LOCAL_MODELS } from "./providers/local.js";

/** Metadata attached to each leaf of ConfigSchema. */
export interface ConfigKeyMeta {
Expand Down Expand Up @@ -47,9 +48,11 @@ export const ConfigSchema = z.object({
nonEmpty()
.optional()
.describe(
"Embedding model. Ignored by the local provider (always sentence-transformers/all-MiniLM-L6-v2).",
`Embedding model. Models of the local provider: ${[...LOCAL_MODELS.keys()].join(", ")}.`,
),
{ defaultText: "ollama: nomic-embed-text; openai: text-embedding-3-small" },
{
defaultText: `local: ${DEFAULT_LOCAL_MODEL}; ollama: nomic-embed-text; openai: text-embedding-3-small`,
},
),
url: leaf(
nonEmpty()
Expand Down
Loading
Loading