CosineSimilarity (database/database.go)

docker-agent · pkg/rag/database/database.go · go · Apache-2.0
database

Go package for calculating vector similarity and defining RAG document structures

// Source: https://github.com/docker/docker-agent | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package database

import (
	"math"
)

// Document represents a chunk of text - the base type returned by all RAG strategies.
// Strategy-specific fields (embeddings, semantic summaries) are handled internally
// by each strategy and don't need to be exposed here.
type Document struct {
	ID         string `json:"id"`
	SourcePath string `json:"source_path"`
	ChunkIndex int    `json:"chunk_index"`
	Content    string `json:"content"`
	FileHash   string `json:"file_hash"`
	CreatedAt  string `json:"created_at"`
}

// SearchResult represents a document with its relevance score.
// This is th

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key