spec

package
v0.0.69 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChromemDocStoreName = "chromemlocal"
	ChromemDocStorePath = "./chromemgo"
)
View Source
const (
	HTTPDocStoreName     = DocumentDBID("http")
	HTTPDocStoreEndpoint = "http://127.0.0.1:8080"
)

Variables

View Source
var HTTPDocStoreHeaders = map[string]string{}

Functions

This section is empty.

Types

type Document

type Document struct {
	ID        DocumentID
	Metadata  map[string]string
	Embedding []float32
	Content   string
}

type DocumentCollection

type DocumentCollection struct {
	ID          DocumentCollectionID
	Name        string
	Documents   map[DocumentID]*Document
	Metadata    map[string]string
	EmbeddingID EmbeddingFuncID
	BasePath    string
	Compress    bool
}

DocumentCollection represents a collection of documents.

type DocumentCollectionID

type DocumentCollectionID string

type DocumentDBID

type DocumentDBID string

type DocumentID

type DocumentID string

type DocumentQueryResult

type DocumentQueryResult struct {
	ID        DocumentID
	Metadata  map[string]string
	Embedding []float32
	Content   string

	// The cosine similarity between the query and the document.
	// The higher the value, the more similar the document is to the query.
	// The value is in the range [-1, 1].
	Similarity float32
}

DocumentQueryResult represents a single result from a query.

type EmbeddingFuncID

type EmbeddingFuncID string
const (
	EmbeddingModelOpenAI3Small              EmbeddingFuncID = "text-embedding-3-small"
	EmbeddingModelOpenAI3Large              EmbeddingFuncID = "text-embedding-3-large"
	EmbeddingModelCohereMultilingualV2      EmbeddingFuncID = "embed-multilingual-v2.0"
	EmbeddingModelCohereEnglishLightV2      EmbeddingFuncID = "embed-english-light-v2.0"
	EmbeddingModelCohereEnglishV2           EmbeddingFuncID = "embed-english-v2.0"
	EmbeddingModelCohereMultilingualLightV3 EmbeddingFuncID = "embed-multilingual-light-v3.0"
	EmbeddingModelCohereEnglishLightV3      EmbeddingFuncID = "embed-english-light-v3.0"
	EmbeddingModelCohereMultilingualV3      EmbeddingFuncID = "embed-multilingual-v3.0"
	EmbeddingModelCohereEnglishV3           EmbeddingFuncID = "embed-english-v3.0"
)

type IDocumentCollection

type IDocumentCollection interface {
	AddDocuments(
		ctx context.Context,
		collectionID DocumentCollectionID,
		documents []Document,
		concurrency int,
	) error
	GetDocumentByID(
		ctx context.Context,
		collectionID DocumentCollectionID,
		id DocumentID,
	) (Document, error)
	DeleteDocumentByID(ctx context.Context, collectionID DocumentCollectionID, id DocumentID) error
	ListDocuments(ctx context.Context, collectionID DocumentCollectionID) ([]*Document, error)

	Query(
		ctx context.Context,
		collectionID DocumentCollectionID,
		queryText string,
		nResults int,
		where, whereDocument map[string]string,
	) ([]DocumentQueryResult, error)
	QueryEmbedding(
		ctx context.Context,
		collectionID DocumentCollectionID,
		queryEmbedding []float32,
		nResults int,
		where, whereDocument map[string]string,
	) ([]DocumentQueryResult, error)
}

type IDocumentDB

type IDocumentDB interface {
	CreateCollection(
		ctx context.Context,
		name string,
		metadata map[string]string,
		embeddingFunc EmbeddingFuncID,
		apiKey string,
	) (*DocumentCollection, error)
	DeleteCollection(ctx context.Context, id DocumentCollectionID) error
	GetCollection(ctx context.Context, id DocumentCollectionID) (*DocumentCollection, error)
	ListCollections(ctx context.Context) (map[DocumentCollectionID]*DocumentCollection, error)
}

IDocumentDB interface for different document storage backends.

Jump to

Keyboard shortcuts

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