api

package
v0.0.0-...-aa8845d Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	ID       string    `json:"id,omitempty"`
	Text     string    `json:"text,omitempty"`
	Vector   []float64 `json:"vector,omitempty"`
	Metadata Metadata  `json:"metadata,omitempty"`

	// Extra data as a JSON string.
	Extra string `json:"extra,omitempty"`
}

type Metadata

type Metadata struct {
	// The source ID of the document.
	//
	// Source/Document has different meanings in different scenarios. For example:
	//
	// 1. Document Splitting
	//   Source => The whole Document
	//   Document => Single Document Chunk
	//
	// 2. Knowledge Base
	//   Source => The whole Knowledge Base
	//   Document => Single Knowledge Point
	SourceID string `json:"source_id,omitempty"`

	// The user ID. Typically useful in multi-tenant scenario.
	UserID string `json:"user_id,omitempty"`

	// The collection name. Only useful for vector stores that support the
	// concept of Collection (e.g. Milvus, Typesense).
	CollectionID string `json:"collection_id,omitempty"`
}

type Similarity

type Similarity struct {
	*Document

	Score float64 `json:"score,omitempty"`
}

type VectorStore

type VectorStore interface {
	//kun:op POST /upsert
	//kun:param __ in=header name=Authorization required=true
	Upsert(ctx context.Context, vendor string, documents []*Document) error

	//kun:op POST /query
	//kun:param __ in=header name=Authorization required=true
	Query(ctx context.Context, vendor string, vector []float64, topK int, minScore float64) (similarities []*Similarity, err error)

	// Delete deletes the chunks belonging to the given sourceIDs.
	// As a special case, empty documentIDs means deleting all chunks.
	//kun:op POST /delete
	//kun:param __ in=header name=Authorization required=true
	Delete(ctx context.Context, vendor string, sourceIDs ...string) error
}

Jump to

Keyboard shortcuts

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