mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 20:44:00 +00:00
f5d1cd67c733a5df459c8cfd7c6a6cc993f1f89c
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
726a6f77a5 |
feat(embeddings): support Cohere v2 endpoints for Foundry text retrieval (#5193)
Continues #2519 (originally contributed by @1jamesthompson1) to address #2518 for text retrieval with Cohere Embed models deployed on Azure AI Foundry. ## Summary Adds an opt-in native Cohere Embed API v2 (`ClientV2`) path to the existing `cohere` embedding registry entry (`CohereEmbeddingFunction`) for text-only retrieval against custom endpoints such as Azure AI Foundry (`https://<resource>.services.ai.azure.com/providers/cohere`, where the Cohere SDK appends `/v2/embed`). ### Behavior and Defaults - **Opt-in v2 route (`base_url`)**: When `base_url` is set, requests use `cohere.ClientV2` (`POST <base_url>/v2/embed`) with `embedding_types=["float"]`, split inputs into batches of up to 96 texts, disable SDK-level retries, and validate returned vector counts and dimensions. Application retries use `retry_with_exponential_backoff` in `embeddings/utils.py`, which adds an optional `do_not_retry` predicate used only by Cohere v2 so `3xx` redirects fail immediately without backoff while transient failures such as `429` retry only the failed batch. Non-string inputs are rejected; this change covers text retrieval only. - **Fixed retrieval roles**: In `base_url` mode, document embeddings use `search_document` and query embeddings use `search_query`. Setting other `source_input_type` or `query_input_type` values is rejected. - **Explicit endpoint parameters**: Setting `base_url` requires explicit `name` (the deployed model name), `output_dimension` (`> 0`, used for both the Arrow vector column width and the v2 request `output_dimension`), and `api_key`. Setting `output_dimension` or `api_key` without `base_url` is rejected. - **Unchanged hosted path**: When `base_url` is omitted, existing behavior is preserved — `cohere.Client` (`/v1/embed`), `COHERE_API_KEY`, existing default model/role settings, legacy table metadata restoration, and the existing `cohere>=4.0` package floor. - **Runtime SDK requirement**: Opting into `base_url` checks `cohere>=5.15.0` at runtime and raises an `ImportError` on older SDK versions without raising the minimum requirement for hosted users. ### Credentials and Endpoint Trust - `api_key` is declared in `sensitive_keys()` and must be a registry `$var:` reference without an inline fallback default (`$var:<name>` only). Table metadata persists only the variable reference. - `base_url` must be an HTTP(S) URL without embedded credentials, query strings, or fragments, and is exposed through `endpoints()` so reopening a table in a new process requires explicit approval via `registry.allow_endpoint(...)`. - `ClientV2` is cached per embedding function instance (`@cached_property`) with `httpx.Client(follow_redirects=False, timeout=300)` so redirects cannot forward requests or credentials off the approved endpoint. Because Cohere v2 classifies `3xx` responses as non-retryable via `do_not_retry`, a redirected `table.add` or `table.search` call makes one `POST` with zero application backoff and no request to the `Location` target (`table.add` surfaces the `307` inside the existing Arrow/Rust `RuntimeError` wrapper; `table.search` surfaces the Cohere `ApiError`). ## Verification - **Loopback HTTP SDK tests (`test_cohere_embeddings.py`)**: Passed against local loopback HTTP fixtures with real Cohere SDK `5.15.0` (opt-in minimum), `7.0.5`, and `7.3.2`. Verified exact `/providers/cohere/v2/embed` path, bearer auth header, JSON payload, 256-dim vector schema, `table.add`/reopen, fresh-process `UntrustedEmbeddingConfigError` followed by `allow_endpoint(...)`, deterministic role-based ranking, 96-text batching with failed-batch-only `429` retry (single backoff), `307` redirect handling with retries enabled on both `table.add` (wrapped in Arrow/Rust `RuntimeError`) and `table.search` (Cohere `ApiError`) with one `POST`, zero application backoff, and no `Location` request, plus invalid input/dimension rejection. - **Adjacent embedding, retry, and trust suites (`cohere==7.3.2`)**: Passed across embedding, registry, trust (including the SDK-independent Cohere metadata restoration and endpoint authorization test in `test_embeddings_trust.py`), field metadata, NVIDIA embedding, and retry suites (OpenAI-key test skipped without a key). - **No-`cohere` environment**: Cohere config/legacy unit tests and SDK-independent `test_embeddings_trust.py` metadata restoration and endpoint authorization tests passed without `cohere` installed (real-SDK loopback tests skipped). - **Legacy SDK (`cohere==4.57`)**: Loopback wire check confirmed hosted document/query requests continue targeting `/v1/embed` and opt-in `base_url` usage raises `Cohere base_url requires cohere>=5.15.0`. - **Docs & lint**: Offline Foundry schema test (`test_embedding_cohere_foundry`), byte-identical regenerated snippet (`docs/web/snippets/integrations.mdx`), and `python/` Ruff format/lint checks passed. ### Scope of Verification All HTTP request, authentication, redirect, trust, and ranking checks were exercised against local loopback HTTP fixtures modeled on [Cohere's Azure Foundry workshop](https://github.com/cohere-ai/cohere-azure-workshops/tree/ca1c4cb162e2/lab-1-embed) and the [Cohere Embed v2 API reference](https://docs.cohere.com/v2/reference/embed). Acceptance against a live Azure AI Foundry service (real Foundry credentials and specific `output_dimension` overrides) has not been verified. |
||
|
|
d605943e9b |
feat(python): add Bedrock image embeddings (#5190)
Continues #2320. Thank you @qingyuan18 for starting this work! ## Summary Adds the `bedrock-image` (`BedrockImage`) embedding function for AWS Bedrock image embeddings, exports it from `lancedb.embeddings`, updates the AWS Bedrock docs, and extracts shared Bedrock runtime client setup into `_BedrockEmbeddingFunction`. - **Models**: - `amazon.titan-embed-image-v1` (default, 1024 dims): PNG and JPEG source images. - `cohere.embed-v4:0` (1536 dims): PNG, JPEG, WebP, and GIF source images (`search_document` for ingestion, `search_query` for queries). Cohere v3 models remain text-only under `bedrock-text`. - **Input & search**: Source columns accept encoded image `bytes` or local file paths (`str`), with format detected from decoded bytes via Pillow and `None` entries yielding `None` embeddings. Queries accept text (`str`) or `PIL.Image.Image` (converted to RGB PNG); `AsyncTable.search` requires `query_type="vector"` for Pillow image queries. - **Credentials**: `bedrock-image` uses `boto3.Session()`'s default credential chain (e.g., `AWS_PROFILE` or the application's IAM role) and rejects `profile_name`, `assumed_role`, and `role_session_name` on both `create()` and metadata restore. `bedrock-text` retains its released `profile_name`, `assumed_role`, and `role_session_name` settings. ## Validation - Local Python tests cover the public `get_registry()` API, Arrow table creation and ingestion (`bytes` and local path sources), table reopen from persisted Arrow metadata, sync text and `PIL.Image` search, async `query_type="vector"` `PIL.Image` search, credential-option rejection on `bedrock-image` create/restore, and `bedrock-text` credential-setting restoration and Cohere v3 text requests. - SDK requests and payloads were validated at the `boto3`/`botocore` `bedrock-runtime` client boundary using `botocore.stub.Stubber`. No live AWS Bedrock service calls were run, so live IAM/STS credential resolution, region model availability, and Bedrock service-side validation are not covered. |
||
|
|
de95ed3f6d |
docs: overhaul curation, feature engineering, security and deployment guides (#4748)
A broad documentation pass across the areas LanceDB Enterprise and Embedded diverge on most: **Data Curation** -- GPU Function execution, Slurm scheduling (and what Slurm is, for readers new to it), blob late materialization as its own page, joins, aggregation/profiling, sampling, near-duplicate detection, chunking, distributed shuffle, and IVF-partition clustering. **Feature Engineering** -- computed columns and materialized views, restructured to lead with the Function-based path and show the SQL form side by side with Python throughout; a single Auto Refresh page instead of duplicating scheduling details on every refresh page; adaptive execution; checkpointing; GPU and Slurm placement for refresh workers; a Training Cache page for the PyTorch data loader's automatic cache benefit. **Security & Governance** -- an Audit Log reference (schema, access, grants), Secrets promoted to an ordinary catalog object with their own SQL DDL and a vending/rotation guide, and privilege-table fixes verified against the authorization source. **Deployment & Maintenance** -- Horizontal Scaling and OpenTelemetry moved into a real Deployment area; Automated Cleanup folded into Intelligent Auto-Maintenance (every other maintenance decision already lived there); RTE Compaction and Advanced Conflict Resolution documented in depth. **Landing page** -- the Enterprise feature comparison table reorganized (several redundant or stale rows removed, several new areas added), and the "why Enterprise" bullets replaced with ones tied to a concrete page (Performance, Scale, Fault tolerance, Multicloud deployment, Simplify operations) instead of vague promises. Plus a full pass addressing lancedb-gatekeeper's review: a real test-safety bug (a quickstart test could silently overwrite and delete a deployment's own `frames` table), a fabricated SQL statement with no backing implementation, an actual dedup-guarantee bug in `take_row_ids`, and dozens of documentation-accuracy fixes verified against source rather than taken on faith -- each either fixed, or left with an explicit note on why it needs a feature or deployment owner's sign-off instead of being guessed at. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018PXMCbRH6i5w47TsjeEUMT --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> |
||
|
|
659ea11ac4 |
fix(embeddings): default Cohere to embed-multilingual-v3.0, the v2.0 models are retired (#4698)
Cohere retired `embed-english-v2.0`, `embed-english-light-v2.0` and `embed-multilingual-v2.0` on April 4, 2026 ([deprecations](https://docs.cohere.com/docs/deprecations), which lists `embed-english-v3.0`, `embed-multilingual-v3.0` and `embed-v4.0` as the embedding alternatives). `CohereEmbeddingFunction` still defaulted to `embed-multilingual-v2.0`, so every call without an explicit `name` fails. The default is now `embed-multilingual-v3.0`, the multilingual v3 model, and the retired models are removed from the docstring and the Cohere integration page (the page also listed `embed-english-v2.0` as the default, which did not match the code). The docs example, its generated snippet, the docs test and the slow Cohere test use the new name. This changes the default vector size: `ndims()` returns 1024 for `embed-multilingual-v3.0`, where the old default gave 768. Tables created from a schema that uses `cohere.ndims()` get 1024-dimension vectors from now on. A table that already holds 768-dimension vectors from the retired model needs a re-embed with a current model, since the old model can no longer be called. The `ndims()` entries for the v2 names are left as they are. Test: `test_cohere_default_model_is_not_a_retired_v2_model` in `python/python/tests/test_embeddings.py` checks the default name and that `ndims()` is 1024. The repository's pytest session could not be run for this change (its `conftest.py` needs a newer native module than the released wheel); the body of that test was run against the released `lancedb` 0.40.0 with this version of `cohere.py` in place, where it passes, and it returns `embed-multilingual-v2.0` / 768 without the change. ruff check and format are clean on the touched Python files. No Cohere request was made. This change was made with Claude Code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Xuanwo <github@xuanwo.io> |
||
|
|
758f738b8c |
docs: complete ingestion, search and integration examples (#4533)
This PR is part of the documentation revamp. Once the full set of PRs is merged, we’ll publish the combined site to staging for review before updating docs.lancedb.com. Ingestion, search and integration examples are incomplete or inconsistent across languages, and some guidance misstates SDK behavior. This brings the guides and their example sources together. It includes complete Python, TypeScript and Rust workflows, isolated provider and reranker examples, the Superlinked corrections, and guidance on retries that can duplicate writes. Stacked on #4491. Each MDX file has one PR owner. Rebase onto main after #4491 is squash-merged. Local assembly, Mint validation and link checks pass. Example code is unchanged from the previously validated package. Publication stays held through integration. |
||
|
|
47b7babc08 |
docs: bring the open-source documentation into this repository (#4122)
Move the public website pages into `docs/web` beside the SDK, with
shared navigation and executable example sources in `docs/web-tests`.
The combined website is assembled by
[lancedb/docs#355](https://github.com/lancedb/docs/pull/355), with six
Enterprise replacements from
[lancedb/sophon#7681](https://github.com/lancedb/sophon/pull/7681).
This includes Function guidance, runnable Quickstarts, regenerated
snippets, production contact/demo fixes, the legacy SQL route, and the
LeRobot redirect. LeRobot remains attributed to Geneva; all 34 Geneva
pages remain in the docs repository until Function officially launches.
Materialized-view guidance follows the full rebuild refresh introduced
by #4373: local refresh writes the complete result, has no `full`
argument, supports `source_version`, and no longer requires stable row
IDs. Deployment SQL refresh options and stable-ID setup are qualified by
version/configuration. Function input guidance distinguishes ordinary
stored columns from computed inputs supported by newer deployments.
**Validation:** independently accepted local checks include 95 Python
tests (real Enterprise excluded), eight TypeScript tests, Rust
Quickstart, snippet parity, typos, deterministic assembly, Mint
validation and links/anchors/redirects. The combined baseline retains
all 181 production routes and 17 legacy redirects. Examples ran locally
against source-built Python SDK 0.40.0b13; existing GitHub workflows do
not run `docs/web-tests`. New main at `069b2f7d` is 0.41.0b0 and adds
computed Function inputs; that SDK was not exercised by the accepted
tests. Latest prose corrections receive focused site validation.
**Merge/rollout:** merge this and #7681 before #355's combined CI, which
reads producer `main`. This is migration infrastructure: section
overlays, source-owned skills and automatic versioned paired releases
remain follow-ups. The current manual publisher is transitional. Hosted
validation, a supported SDK/Enterprise release pair and a real
Enterprise walkthrough remain pending.
Production Mintlify watches `lancedb/docs:deploy-freeze`, directory
`docs`; preserve that source through review. The separate SDK GitHub
Pages reference workflow rebuilds on main merges.
**Updated-head CI (
|