embeddingutil

package
v1.5.2-hotfix Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyManagedEmbedding

func ApplyManagedEmbedding(node *storage.Node, embeddings [][]float32, model string, dimensions int, embeddedAt time.Time)

ApplyManagedEmbedding writes worker-compatible embedding payload to node fields.

func BuildText

func BuildText(properties map[string]interface{}, labels []string, opts *EmbedTextOptions) string

BuildText creates canonical embedding text from node properties and labels.

func ChunkCount

func ChunkCount(meta map[string]any) int

ChunkCount is the number of chunks meta's embedding has, whichever integer type the stored form decoded into; -1 when meta records none.

func InvalidateManagedEmbeddings

func InvalidateManagedEmbeddings(node *storage.Node)

InvalidateManagedEmbeddings clears worker-managed embedding state on a node.

func IsMetadataPropertyKey

func IsMetadataPropertyKey(key string) bool

IsMetadataPropertyKey reports whether a property key is internal embedding metadata.

func RecordChunkSpans

func RecordChunkSpans(node *storage.Node, source EmbedText, chunks []string)

RecordChunkSpans stores where each of node's chunks lies in its string properties, from the text the chunks were cut from. It replaces any spans of an earlier embedding, and stores none when the chunks don't match the node's chunk embeddings one to one (a multimodal document's single vector).

func TextPolicy

TextPolicy is opts as storage's embedding text policy.

Types

type ChunkSpan

type ChunkSpan struct {
	Chunk      int
	Property   string
	Start, End int
}

ChunkSpan is where a chunk of a node's embedding text lies in one of its string properties: [Start, End) in Unicode code points of the value, as Cypher's substring() counts. A chunk that runs across two properties has one span in each.

func StoredChunkSpans

func StoredChunkSpans(meta map[string]any) (spans []ChunkSpan, ok bool)

StoredChunkSpans returns the chunk spans RecordChunkSpans stored in meta, whichever integer types the stored form decoded into; ok is false when meta holds none (an embedding made before spans were recorded).

type EmbedText

type EmbedText struct {
	Policy storage.EmbeddingTextPolicy
	Text   string
	// contains filtered or unexported fields
}

EmbedText is a node's embedding text, with where each string property's value lies in it, so a chunk of the text can be traced to its properties.

func BuildEmbedText

func BuildEmbedText(properties map[string]interface{}, labels []string, opts *EmbedTextOptions) EmbedText

BuildEmbedText creates canonical embedding text from node properties and labels, as BuildText, and records where each string property's value lies.

func (EmbedText) ChunkSpans

func (t EmbedText) ChunkSpans(chunks []string) []ChunkSpan

ChunkSpans finds each chunk in the text (textchunk.Align) and returns the parts of the string property values it covers, with leading and trailing whitespace left out. A chunk not found in the text, or one covering only labels, keys or non-string values, has no span.

type EmbedTextOptions

type EmbedTextOptions struct {
	Include       []string
	Exclude       []string
	IncludeLabels bool
}

EmbedTextOptions controls which properties and labels are used when building embedding text.

func EmbedTextOptionsFromConfig

func EmbedTextOptionsFromConfig(cfg *config.Config) *EmbedTextOptions

EmbedTextOptionsFromConfig maps runtime embedding worker config to text builder options.

func EmbedTextOptionsFromFields

func EmbedTextOptionsFromFields(include []string, exclude []string, includeLabels bool) *EmbedTextOptions

EmbedTextOptionsFromFields builds text options from raw include/exclude settings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL