Skip to content

embedding component ​

The embedding component runs one embedding operation and returns a structured result: a SQLite keyword store for index, search, upsert, and delete, an embedding backend for vectorize and embed_query, and Cohere for rerank. It is a kdeps component from the components asset set: call it with a component: resource, no install step. Its call is the kdeps API's embedding tool, which runs the native embedding executor. A workflow that uses embedding: directly - primary or in a before:/after: step - is rejected.

It works in both modes: as a DAG step in workflow mode, and inside any workflow the LLM calls as a tool in agent mode.

component: embeddingPOST /tools/embedding/callSQLite keyword storeindex, search, upsert, deleteembedding backendvectorize, embed_queryCoherererankresult mapoperation index/search/upsert/deleteoperation vectorize/embed_queryoperation rerank

Configuration ​

yaml
# resources/store.yaml
actionId: store
name: Store Document
component:
  name: embedding                   # from the components asset set; a components/embedding/ of your own wins
  with:
    operation: index                # required: index | search | upsert | delete | vectorize | embed_query | rerank
    text: "{{ get('text') }}"       # text to index, search for, upsert or delete
    collection: docs                # optional namespace (default: "default")
    dbPath: /data/store.db          # optional SQLite path; default from the kdeps embedding defaults
    limit: 5                        # optional max search results
InputTypeRequiredDefaultDescription
operationstringyes-index, search, upsert, delete, vectorize, embed_query, or rerank
textstringsee below-Text to index, search for, upsert, or delete. Required for index, search, and upsert; empty deletes the whole collection on delete
collectionstringno"default"Namespace inside the SQLite database
dbPathstringnokdeps embedding defaultSQLite database file path
limitnumbernokdeps embedding defaultMax results for search
inputsarrayyes for vectorize, embed_query-Texts to embed
modelstringnobackend defaultEmbedding model, e.g. text-embedding-3-small
backendstringnokdeps LLM backendopenai, ollama, or google
baseURLstringno-Custom base URL for an OpenAI-compatible backend
rerankQuerystringyes for rerank-Query the candidate documents are ranked against
rerankDocumentsarrayyes for rerank-Candidate documents to rerank
rerankTopNnumberno0 (all)Number of top reranked results

Operations ​

OperationBackingDescription
indexSQLiteInsert text (ignored if duplicate)
upsertSQLiteInsert or replace text
searchSQLiteCase-insensitive keyword search via LIKE
deleteSQLiteDelete by text, or the whole collection when text is empty
vectorizeembedding backendConvert inputs into vectors
embed_queryembedding backendConvert text into a query vector
rerankCohereRank rerankDocuments against rerankQuery

Output ​

json
{
  "operation": "search",
  "collection": "docs",
  "query": "compiled language",
  "results": ["Go is a statically typed, compiled programming language."],
  "count": 1,
  "json": "{\"collection\":\"docs\",...}"
}

Read fields with output('store').results, output('store').count, and so on.

KeyTypeDescription
operationstringThe operation that was performed
collectionstringThe collection used
successbooltrue on success
results[]stringMatching texts (search only)
countintegerNumber of results (search only)
affectedintegerRows deleted (delete only)
jsonstringFull result as a JSON string

A failed operation does not return this map: the call fails and onError: on the resource decides what happens next.

Examples ​

Build a RAG pipeline ​

yaml
# Step 1: Scrape content
actionId: fetch
component:
  name: web_scraper
  with:
    url: "{{ get('url') }}"

# Step 2: Index it
actionId: storeDoc
requires: [fetch]
component:
  name: embedding
  with:
    operation: index
    text: "{{ output('fetch').content }}"
    collection: knowledge
    dbPath: /data/store.db

# Step 3: Search on user query
actionId: findDocs
component:
  name: embedding
  with:
    operation: search
    text: "{{ get('query') }}"
    collection: knowledge
    dbPath: /data/store.db
    limit: 5

# Step 4: Answer with context
actionId: answer
requires: [findDocs]
chat:
  model: llama3.2:1b
  prompt: |
    Context: {{ output('findDocs').results }}
    Question: {{ get('query') }}
apiResponse:
  response: "{{ output('answer') }}"

Vector embeddings ​

yaml
# resources/embed.yaml
actionId: embed
component:
  name: embedding
  with:
    operation: vectorize
    inputs: ["{{ get('text') }}"]    # texts to embed
    model: text-embedding-3-small
    backend: openai                  # KDEPS_OPENAI_API_KEY or ~/.kdeps/config.yaml

Collections ​

Use collection to namespace documents - useful for multi-tenant or multi-topic stores:

yaml
# Index into separate collections
component:
  name: embedding
  with:
    operation: index
    text: "..."
    collection: contracts

# Search only within one collection
component:
  name: embedding
  with:
    operation: search
    text: termination clause
    collection: contracts

Note: index, search, upsert, and delete use keyword (LIKE) matching, not vector similarity. Use vectorize and embed_query with a backend for vector embeddings.

See also ​

Released under the Apache 2.0 License.