Function Types
Enrich Functions
Add context from knowledge bases using semantic search
Enrich functions perform semantic search against collections to add contextual information to your data. They're useful for looking up reference data, adding context from knowledge bases, or matching against existing records.
When to Use
Use an Enrich function when you need to:
- Look up vendor information from a master list
- Match extracted data against existing records
- Add context from a knowledge base or documentation
- Find similar items in a collection
- Validate data against reference sources
Prerequisites
Before creating an Enrich function, you need:
- A Collection with your reference data
- Items added to the collection with searchable content
See the Collections API for creating and populating collections.
Configuration Fields
Required Fields
| Field | Type | Description |
|---|---|---|
functionName | string | Unique identifier for the function |
type | string | Must be "enrich" |
config | object | Enrichment configuration |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
displayName | string | - | Human-readable display name |
tags | string[] | - | Tags for organization |
Enrich Config
The config object contains:
| Field | Type | Description |
|---|---|---|
collectionName | string | Name of the collection to search |
| Additional config options vary based on enrichment type |
Example
Vendor Lookup
Enrich invoice data with vendor information from a master vendor list:
{
"functionName": "vendor-enricher",
"type": "enrich",
"displayName": "Vendor Information Lookup",
"config": {
"collectionName": "vendor-master-list"
},
"tags": ["vendor", "lookup"]
}Product Matching
Match extracted product names against a product catalog:
{
"functionName": "product-matcher",
"type": "enrich",
"displayName": "Product Catalog Matcher",
"config": {
"collectionName": "product-catalog"
},
"tags": ["products", "matching"]
}Workflow Pattern
Enrich functions typically follow Transform functions:
Document
│
▼
┌───────────┐
│ Transform │ Extract raw data
└───────────┘
│
▼
┌───────────┐
│ Enrich │ Add context from collection
└───────────┘
│
▼
Enriched OutputExample Flow
- Transform extracts vendor name "Acme Corp" from invoice
- Enrich searches vendor collection for "Acme Corp"
- Output includes matched vendor ID, address, payment terms
Setting Up Collections
Before using Enrich functions, create and populate a collection:
# Create collection
curl -X POST https://api.bem.ai/v2/collections \
-H "Authorization: Bearer $API_KEY" \
-d '{
"name": "vendor-master-list",
"description": "Master list of approved vendors"
}'
# Add items
curl -X POST https://api.bem.ai/v2/collections/vendor-master-list/items \
-H "Authorization: Bearer $API_KEY" \
-d '{
"items": [
{
"content": "Acme Corporation - Primary supplier for office supplies",
"metadata": {
"vendorId": "V001",
"paymentTerms": "Net 30"
}
}
]
}'