embed

package
v0.0.0-...-db187aa Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultChunkOverlap = 128
View Source
const DefaultChunkSize = 512
View Source
const DefaultModel = "all-minilm"

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	gorm.Model
	Title      string
	Author     string
	Embeddings []BookEmbedding
}

type BookEmbedding

type BookEmbedding struct {
	gorm.Model
	BookID    uint
	Text      string
	Embedding pgvector.Vector `gorm:"type:vector(384)"`
}

type Chunker

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

func NewChunker

func NewChunker(chunkSize, chunkOverlap int) (*Chunker, error)

func (*Chunker) Chunk

func (c *Chunker) Chunk(ctx context.Context, rdr io.Reader) ([]string, error)

type EndpointRequest

type EndpointRequest struct {
	Model  string `json:"model"`
	Prompt string `json:"prompt"`
}

type EndpointResponse

type EndpointResponse struct {
	Embedding []float32 `json:"embedding"`
}

type Generator

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

func NewGenerator

func NewGenerator(httpClient *http.Client, endpoint *url.URL, model string) (*Generator, error)

func (*Generator) Generate

func (g *Generator) Generate(ctx context.Context, text string) ([]float32, error)

Jump to

Keyboard shortcuts

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