feat(python): add AssetFeed embedding provider (#5257)

Adds an `assetfeed` text embedding provider for the AssetFeed embeddings
API (`assetfeed/assetfeed-embed-v1`). It uses the existing optional
`openai` client with AssetFeed's OpenAI-compatible endpoint, as the
`nvidia` provider does.

- Documents are embedded with `input_type="document"`, searches with
`input_type="query"`.
- `dim` is 1024 (default), 512 or 256. Batches are at most 64 inputs.
- The key comes from `ASSETFEED_API_KEY` or an `api_key` registry
variable reference.
- Response count, indices, dimensions and values are checked. Null and
empty text get a null vector without a request.
- Each request is retried on its own with LanceDB's retry policy.

Python and docs only (`integrations/embedding/assetfeed`). No dependency
changes.

### Testing

- `test_assetfeed_embeddings.py`: 18 mocked-HTTP tests through the real
OpenAI client, no network. They cover request shape, batching, response
order, null inputs, a local table, retries and invalid responses.
- Registry and trust suites: pass. `ruff check` passes.
- Not tested live: no API key was used.

---
This commit is contained in:
Nikolai Vysotskyi
2026-11-30 20:18:29 +08:00
committed by GitHub
parent d0dfa0d8f0
commit 41637c646e
5 changed files with 429 additions and 0 deletions
+1
View File
@@ -625,6 +625,7 @@
"group": "Embedding Providers",
"pages": [
"integrations/embedding/huggingface",
"integrations/embedding/assetfeed",
"integrations/embedding/aws",
"integrations/embedding/cohere",
"integrations/embedding/colpali",
@@ -0,0 +1,81 @@
---
title: AssetFeed
sidebarTitle: AssetFeed
description: Text embeddings with assetfeed-embed-v1 in the LanceDB Python SDK.
---
The Python SDK registers `assetfeed` for client-side text embedding with the
[AssetFeed embeddings API](https://assetfeed.com/models/embeddings). Documents are
sent with `input_type="document"` and searches with `input_type="query"`. Null and
empty text values get a null vector without a request.
Create an API key at [assetfeed.com/api-keys](https://assetfeed.com/api-keys), then
install the optional client and set the key:
<CodeGroup>
```bash Bash icon="terminal"
pip install openai
export ASSETFEED_API_KEY="your-api-key"
```
</CodeGroup>
<CodeGroup>
```python Python icon="python"
import lancedb
from lancedb.embeddings import get_registry
from lancedb.pydantic import LanceModel, Vector
func = get_registry().get("assetfeed").create(dim=512)
class Document(LanceModel):
text: str = func.SourceField()
vector: Vector(func.ndims()) = func.VectorField()
db = lancedb.connect("./assetfeed-db")
table = db.create_table("documents", schema=Document)
table.add([{"text": "Bitcoin ETF inflows rose for a fifth week."}])
results = table.search("ETF flows").limit(3).to_list()
```
</CodeGroup>
## Null and empty text
Null and empty text values get a null vector, and `table.add()` rejects a batch with a null
vector under its default write policy. To keep those rows, make the text and vector columns
nullable and pass `on_bad_vectors="null"`:
<CodeGroup>
```python Python icon="python"
from typing import Optional
class NullableDocument(LanceModel):
text: Optional[str] = func.SourceField()
vector: Optional[Vector(func.ndims())] = func.VectorField()
table = db.create_table("documents_nullable", schema=NullableDocument)
table.add(
[{"text": "Bitcoin ETF inflows rose for a fifth week."}, {"text": None}, {"text": ""}],
on_bad_vectors="null",
)
```
</CodeGroup>
Pass `on_bad_vectors="drop"` instead to skip those rows.
## Model and configuration
| Model ID | Dimensions | Inputs per request | Truncation |
|---|---|---|---|
| `assetfeed/assetfeed-embed-v1` | 1024, 512 or 256 | up to 64 | queries at 512 tokens, documents at 1024 tokens |
| Parameter | Default | Description |
|---|---|---|
| `name` | `assetfeed/assetfeed-embed-v1` | Model ID. |
| `dim` | `1024` | Output dimensions: `1024`, `512` or `256`. |
| `api_key` | `ASSETFEED_API_KEY` | Alternatively, a registry reference such as `$var:assetfeed-key`. |
| `batch_size` | `64` | Maximum inputs per request, at most 64. |
| `max_retries` | `7` | LanceDB's retry policy, applied to each request. |
Requests go to `https://api.assetfeed.com/api/v1/models/embeddings` in the OpenAI
embeddings format. See the [AssetFeed embeddings page](https://assetfeed.com/models/embeddings)
for the model description and [pricing](https://assetfeed.com/pricing).