Documentation
¶
Index ¶
Constants ¶
View Source
const ( WriteModeInsert = "insert" // always append if not exists WriteModeUpdate = "update" // insert or update WriteModeReset = "reset" // always overwrite WriteModeOnlyGreater = "only_greater" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBResult ¶
type DBResult struct {
ID string `json:"id,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Embedding []float32 `json:"embedding,omitempty"`
Content string `json:"content"`
// 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 `json:"similarity,omitempty"`
}
DBResult represents a single result from a query.
type IVectorDB ¶
type IVectorDB interface {
Open() (err error)
Close()
String() string // return serialized options
Load(filename string, writeMode string) (err error)
AddToCollection(collName string, writeMode string, docs ...interface{}) (err error)
DeleteCollection(name string) (err error)
GetCollection(name string, params ...interface{}) (response IVectorDBCollection, err error)
GetOrCreateCollection(name string, params ...interface{}) (response IVectorDBCollection, err error)
SchemaGetCollections() []string
SchemaGetCollectionHash(collName string) string
SchemaGetCollectionSources(name string) []string
SchemaAddCollectionSources(name string, source ...string) []string
SchemaRemoveCollectionSources(name string, source ...string) []string
}
type IVectorDBCollection ¶
type IVectorDBCollection interface {
Count() (response int)
GetById(ctx context.Context, id string) (response *DBResult, err error)
InsertDocument(ctx context.Context, doc interface{}) error
InsertDocuments(ctx context.Context, docs ...interface{}) error
UpdateDocument(ctx context.Context, doc interface{}) (err error)
UpdateDocuments(ctx context.Context, docs ...interface{}) (err error)
Delete(ctx context.Context, params ...interface{}) (err error)
DeleteById(ctx context.Context, id string) (err error)
Query(ctx context.Context, params ...interface{}) (response []*DBResult, err error)
}
Click to show internal directories.
Click to hide internal directories.