Documentation
¶
Overview ¶
Package ragkit provides utility functions for RAG (Retrieval-Augmented Generation) applications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateID ¶
GenerateID creates a deterministic UUID v5 from the input text and metadata. The generated ID is guaranteed to be unique for different inputs.
func ToCamelCase ¶ added in v0.1.4
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 {
// EmbedText: Convert a single text to an embedding vector
EmbedText(ctx context.Context, text string) ([]float32, error)
// EmbedTexts: Convert texts to embedding vectors
EmbedTexts(ctx context.Context, texts ...string) ([][]float32, error)
fmt.Stringer
}
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, metadataFieldNames ...string) ([]RetrievedDoc, error)
// RetrieveText: Return top-K documents based on text query
RetrieveText(ctx context.Context, text string, topK int, metadataFieldNames ...string) ([]RetrievedDoc, error)
}
Retriever is a type that can retrieve documents from a vector database
Directories
¶
| Path | Synopsis |
|---|---|
|
embedder
|
|
|
examples
|
|
|
weaviate-ollama
command
|
|
|
weaviate-openai
command
|
|
|
vector_store
|
|
Click to show internal directories.
Click to hide internal directories.
