Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateID ¶
GenerateID: Generate a unique ID for a document
Types ¶
type Document ¶
type Document struct {
ID string // Unique ID
Text string // Original text
Metadata map[string]any // Optional: Additional metadata
Vector []float32 // Optional: Embedding vector (generated by Embeder if not provided)
}
Document is a type that represents a document
type Embedder ¶
type Embedder interface {
// Embed: Convert texts to embedding vectors
Embed(ctx context.Context, texts ...string) ([][]float32, error)
}
Embedder is a type that can embed texts into vectors
type Indexer ¶
type Indexer interface {
// Index: Index multiple documents
// Returns: IDs of indexed documents
Index(ctx context.Context, docs ...Document) ([]string, error)
// Delete: Delete a document by ID
Delete(ctx context.Context, id string) error
// Exists: Check if a document with the given ID exists
Exists(ctx context.Context, id string) (bool, error)
}
Indexer is a type that can index documents into a vector database
type RetrievedDoc ¶
type RetrievedDoc struct {
// ID string // Document ID
// Score float32 // Similarity score
Vector []float32 // Retrieved vector
Text string // Retrieved text
Metadata map[string]any // Optional metadata
}
RetrievedDoc is a type that represents a retrieved document from vector database
type Retriever ¶
type Retriever interface {
// Retrieve: Return top-K documents based on query vector
Retrieve(ctx context.Context, query []float32, topK int) ([]RetrievedDoc, error)
// RetrieveText: Return top-K documents based on text query
RetrieveText(ctx context.Context, text string, topK int) ([]RetrievedDoc, error)
}
Retriever is a type that can retrieve documents from a vector database
type Vectorizer ¶
Vectorizer is a combination of Indexer and Retriever
Click to show internal directories.
Click to hide internal directories.
