You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fedb4f8
Browse filesBrowse the repository at this point in the historyBrowse files
docs(readme): real quickstart, EmbeddingRequestError, CONTRIBUTING (CL-9089)
The quickstart embeds two strings with a literal config and prints the
count and width; no env loader, spread, or manual deps. Errors document
EmbeddingRequestError, the internal transport section is gone, the
@intx/inference paragraph appears once under Using with Interchange, and
Versioning/Development move to CONTRIBUTING.md.
Also closes CL-9093, CL-9090, CL-9098.
Copy file name to clipboardExpand all lines: README.md
+17-70Lines changed: 17 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,6 @@ OpenAI, Ollama, TEI, vLLM, and Jina all serve the same wire shape. This package
8
8
-`encodingFormat` — `float` (default) or compact `base64`.
9
9
-`batchSize` — inputs per request (default 32). Tune it to provider caps and per-request token ceilings.
10
10
11
-
Transport, error classification, and retry build on `@intx/inference`: requests go through the shared `deps.fetch` path, failures classify into `InferenceError` just like chat calls, and `createDefaultRetryPolicy` guides backoff. A 429 from an embeddings endpoint behaves like one from a chat endpoint, and credential failures short-circuit.
12
-
13
11
## Install
14
12
15
13
```bash
@@ -20,85 +18,34 @@ Runs on Bun >= 1.2 or Node >= 24. The built `dist/` entry is the default import.
20
18
21
19
## Quickstart
22
20
23
-
This package never touches credential storage or config sources — it takes an
24
-
already-built `EmbedConfig`. Where that config comes from is the host's
25
-
choice; `@corbits/memory`, for example, reads it straight from
26
-
`EMBED_BASE_URL`/`EMBED_MODEL`/`EMBED_API_KEY` env vars, all-or-nothing on the
27
-
first two. A host wraps `embedTexts` in a function of its own that builds the
28
-
config once (at startup, or per call) and probes dimensionality up front so a
29
-
later model swap is caught as a migration, not a silent width mismatch.
`embedTexts(texts, config, options)` batches sequentially, posts each batch to
66
-
`{baseURL}/embeddings`, and returns vectors in input order. `options`carries
67
-
`deps` (a host's real`fetch`plus`createDefaultScheduler()`, the production
68
-
scheduler), with optional `retryPolicy`, `extractRetryAfterMs`, and `signal`.
33
+
`embedTexts(texts, config, options?)` batches sequentially, posts each batch to
34
+
`{baseURL}/embeddings`, and returns vectors in input order. `options`is
35
+
optional: `deps` (defaults to global`fetch`and`createDefaultScheduler()`),
36
+
`retryPolicy`, `extractRetryAfterMs`, and `signal`.
69
37
70
38
## Dimensionality
71
39
72
-
`probeEmbedDims(config, { deps })` embeds one probe string and reports the length received. Dimensionality follows the provider and the `dimensions` setting, so callers that persist vectors discover it at startup and treat a model swap as a migration. Representative widths: 1536 for OpenAI `text-embedding-3-small`, 768 for `nomic-embed-text`, 384 for `bge-small-en-v1.5`.
40
+
`probeEmbedDims(config)` embeds one probe string and reports the length received. Dimensionality follows the provider and the `dimensions` setting, so callers that persist vectors discover it at startup and treat a model swap as a migration. Representative widths: 1536 for OpenAI `text-embedding-3-small`, 768 for `nomic-embed-text`, 384 for `bge-small-en-v1.5`.
73
41
74
42
## Errors
75
43
76
-
Every failure mode — transport, HTTP status, or a 200 with an unexpected body — raises `ModelRequestError`, carrying the classified `InferenceError` as `reason` plus the request URL. The embedding and reranking packages each carry their own copy of this class while the shared transport is upstreamed, so code catching both discriminates on `error.name === "ModelRequestError"`.
77
-
78
-
## Lower-level: transport
79
-
80
-
The barrel also re-exports the one-shot JSON transport `embedTexts` is built on, for sibling clients that want the same classified, retried request path:
81
-
82
-
-`runJSONRequest` — one JSON POST with error classification and retry.
83
-
-`extractRetryAfterMs` — default `Retry-After` reader, overridable per call.
84
-
-`ModelRequestError` — error for every failure mode, with `reason` and URL.
85
-
- Types `RunRequestOptions` and `RetryAfterExtractor`.
44
+
Every failure — transport, HTTP status, or a 200 with an unexpected body — throws `EmbeddingRequestError` (`extends Error`), carrying the classified `InferenceError` as `reason` and the request `url`. A config that fails `EmbedConfigSchema` throws before any request.
86
45
87
-
## Interchange
46
+
## Using with Interchange
88
47
89
-
Built on the shared `@intx/inference` transport, so an embeddings call fails and retries the same way a chat call does: same `deps.fetch` path, same `InferenceError` classification, same `createDefaultRetryPolicy` backoff. A retrieval pipeline typically pairs `probeEmbedDims` at startup with `embedTexts` batches at ingest and query time, as described above.
90
-
91
-
## Versioning
92
-
93
-
Semver. Releases run `bun run build && npm publish` with green CI.
94
-
95
-
## Development
96
-
97
-
```bash
98
-
bun install
99
-
bun test ./src
100
-
bunx tsc --noEmit
101
-
```
48
+
Transport, error classification, and retry build on `@intx/inference`: requests go through `deps.fetch`, failures classify into `InferenceError` just like chat calls, and `createDefaultRetryPolicy` guides backoff. A 429 from an embeddings endpoint behaves like one from a chat endpoint, and credential failures short-circuit. `@intx/inference` and `@intx/types` are peer dependencies, so the host's Interchange version is the one used.
0 commit comments