milvus

package
v0.0.0-...-914b2b8 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 9 Imported by: 1

README

Milvus

Using Milvus as the vector store.

Installation

For how to install Milvus in different scenarios, see Official Documents.

For testing purpose, here we choose to Install Milvus Standalone with Docker Compose.

$ wget https://github.com/milvus-io/milvus/releases/download/v2.2.4/milvus-standalone-docker-compose.yml -O docker-compose.yml
$ sudo docker compose up -d

Testing

$ go test -v -race
=== RUN   TestMilvus_Query
--- PASS: TestMilvus_Query (7.34s)
PASS
ok  	github.com/go-aie/gptbot/milvus	7.866s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// CollectionName is the collection name.
	// This field is required.
	CollectionName string

	// CreateNew specifies whether to overwrite if the collection already exists.
	CreateNew bool

	// Addr is the address of the Milvus server.
	// Defaults to "localhost:19530".
	Addr string

	// Dim is the embedding dimension.
	// Defaults to 1536 (the dimension generated by OpenAI's Embedding API).
	Dim int
}

type Milvus

type Milvus struct {
	// contains filtered or unexported fields
}

func NewMilvus

func NewMilvus(cfg *Config) (*Milvus, error)

func (*Milvus) Delete

func (m *Milvus) Delete(ctx context.Context, documentIDs ...string) error

Delete deletes the chunks belonging to the given documentIDs. As a special case, empty documentIDs means deleting all chunks.

func (*Milvus) Insert

func (m *Milvus) Insert(ctx context.Context, chunks map[string][]*gptbot.Chunk) error

func (*Milvus) LoadJSON

func (m *Milvus) LoadJSON(ctx context.Context, filename string) error

func (*Milvus) Query

func (m *Milvus) Query(ctx context.Context, embedding gptbot.Embedding, corpusID string, topK int) ([]*gptbot.Similarity, error)

Query searches similarities of the given embedding with default consistency level.

Jump to

Keyboard shortcuts

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