embed

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentRequest added in v1.0.0

type DocumentRequest struct {
	Ctx            context.Context `json:"-"`
	Model          Model           `json:"model"`
	DocumentChunks []string        `json:"document_chunks"`
}

func NewDocumentRequest added in v1.0.0

func NewDocumentRequest(ctx context.Context, model Model, chunks []string) *DocumentRequest

type DocumentResponse added in v1.0.0

type DocumentResponse struct {
	Embeddings [][]float64     `json:"embeddings"`
	Metadata   models.Metadata `json:"metadata,omitempty"`
}

func (*DocumentResponse) AsFloat32 added in v1.0.0

func (r *DocumentResponse) AsFloat32() [][]float32

func (*DocumentResponse) AsFloat64 added in v1.0.0

func (r *DocumentResponse) AsFloat64() [][]float64

type Embeder

type Embeder interface {
	Provider() string
	Embed(req *Request) (*Response, error)
	EmbedDocument(req *DocumentRequest) (*DocumentResponse, error)
}

type Model

type Model struct {
	Provider string `json:"provider"`
	Name     string `json:"name"`

	Type Type `json:"type,omitempty"`

	Description string `json:"description,omitempty"`

	InputMaxTokens   int `json:"input_max_tokens,omitempty"`
	OutputDimensions int `json:"output_dimensions,omitempty"`

	Config map[string]any `json:"config,omitempty"`
}

func ToModel added in v0.11.1

func ToModel(fqn string) (Model, error)

func (Model) FQN

func (m Model) FQN() string

func (Model) String

func (m Model) String() string

func (Model) WithType added in v0.11.0

func (m Model) WithType(mode Type) Model

type Request

type Request struct {
	Ctx   context.Context `json:"-"`
	Model Model           `json:"model"`
	Texts []string        `json:"texts"`
}

func NewManyRequest added in v1.0.0

func NewManyRequest(ctx context.Context, model Model, texts []string) *Request

func NewSingleRequest added in v1.0.0

func NewSingleRequest(ctx context.Context, model Model, text string) *Request

func (*Request) FirstText added in v1.0.0

func (r *Request) FirstText() string

func (*Request) IsSingle added in v1.0.0

func (r *Request) IsSingle() bool

type Response

type Response struct {
	Embeddings [][]float64     `json:"embeddings"`
	Metadata   models.Metadata `json:"metadata,omitempty"`
}

func (*Response) AsFloat32 added in v0.9.1

func (r *Response) AsFloat32() [][]float32

func (*Response) AsFloat64 added in v0.9.1

func (r *Response) AsFloat64() [][]float64

func (*Response) Many added in v1.0.0

func (r *Response) Many() [][]float64

func (*Response) Single added in v1.0.0

func (r *Response) Single() ([]float64, error)

func (*Response) SingleAsFloat32 added in v1.0.0

func (r *Response) SingleAsFloat32() ([]float32, error)

func (*Response) SingleAsFloat64 added in v1.0.0

func (r *Response) SingleAsFloat64() ([]float64, error)

type Type added in v0.11.0

type Type string
const (
	TypeQuery    Type = "query"
	TypeDocument Type = "document"
	TypeNone     Type = ""
)

Jump to

Keyboard shortcuts

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