Home / Function/ mapEmbeddingsToSections() — supabase Function Reference

mapEmbeddingsToSections() — supabase Function Reference

Architecture documentation for the mapEmbeddingsToSections() function in utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  7e95d843_ee70_bdbc_e71b_eeaab259c8a0["mapEmbeddingsToSections()"]
  b6da1e2f_3534_5430_6fdb_1a60bda504b3["processEmbeddingBatch()"]
  b6da1e2f_3534_5430_6fdb_1a60bda504b3 -->|calls| 7e95d843_ee70_bdbc_e71b_eeaab259c8a0
  style 7e95d843_ee70_bdbc_e71b_eeaab259c8a0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/scripts/search/embeddings/utils.ts lines 37–66

export function mapEmbeddingsToSections(
  batch: PageSectionForEmbedding[],
  data: Array<{ embedding?: number[] }>,
  batchNumber: number
): {
  sectionsWithEmbeddings: PageSectionWithEmbedding[]
  failedSectionIndexes: Set<number>
} {
  const sectionsWithEmbeddings: PageSectionWithEmbedding[] = []
  const failedSectionIndexes: Set<number> = new Set()

  if (batch.length !== data.length) {
    console.error(
      `Ignoring all embeddings returned from batch ${batchNumber} because returned number doesn't match input number`
    )
    batch.forEach((_, index) => {
      failedSectionIndexes.add(index)
    })
  }

  for (let i = 0; i < batch.length; i++) {
    if (data[i].embedding) {
      sectionsWithEmbeddings.push({ ...batch[i], embedding: data[i].embedding! })
    } else {
      failedSectionIndexes.add(i)
    }
  }

  return { sectionsWithEmbeddings, failedSectionIndexes }
}

Subdomains

Frequently Asked Questions

What does mapEmbeddingsToSections() do?
mapEmbeddingsToSections() is a function in the supabase codebase.
What calls mapEmbeddingsToSections()?
mapEmbeddingsToSections() is called by 1 function(s): processEmbeddingBatch.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free