feat: add structured content extraction and batch embedding optimization to highlight()
Fix highlight() hanging on structured text input by addressing 3 root causes:
1. embedBatch() now uses native WASM batch API (single forward pass instead
of N individual embed() calls via Promise.all)
2. highlight() auto-detects content type (plain text, rich-text JSON, HTML,
Markdown) and extracts meaningful text segments. Supports TipTap, Slate.js,
Lexical, Draft.js, and Quill Delta formats. New contentType hint and
contentExtractor callback for custom parsers.
3. Semantic matching phase has 10s timeout - falls back to text-only matches
instead of hanging indefinitely.
Also fixes extractTextContent() array check: uses type-based detection
(typeof data[0] === 'number') instead of length-based (data.length > 10)
so arrays of objects are properly indexed for text search.
New types: ContentType, ContentCategory, ExtractedSegment
New fields: HighlightParams.contentType, HighlightParams.contentExtractor,
Highlight.contentCategory
This commit is contained in:
parent
2b901974ed
commit
cca1cd8ce2
12 changed files with 1341 additions and 37 deletions
|
|
@ -507,14 +507,16 @@ console.log(vector.length) // 384
|
|||
|
||||
---
|
||||
|
||||
### `async embedBatch(texts: string[]): Promise<number[][]>` ✨ *v7.1.0*
|
||||
Batch embed multiple texts efficiently.
|
||||
### `async embedBatch(texts: string[]): Promise<number[][]>` ✨ *v7.1.0, Optimized v7.9.0*
|
||||
Batch embed multiple texts using native WASM batch API (single forward pass).
|
||||
|
||||
**Parameters:**
|
||||
- `texts` - Array of strings to embed
|
||||
|
||||
**Returns:** Array of 384-dimensional vectors
|
||||
|
||||
> **v7.9.0**: Uses the engine's native `embed_batch()` for a single model forward pass instead of N individual `embed()` calls.
|
||||
|
||||
**Example:**
|
||||
```typescript
|
||||
const embeddings = await brain.embedBatch([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue