jina

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmbeddingTypeFloat     EmbeddingType        = "float"
	DefaultBaseAPIEndpoint                      = "https://api.jina.ai/v1/embeddings"
	DefaultEmbeddingModel  types.EmbeddingModel = "jina-embeddings-v2-base-en"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddingRequest

type EmbeddingRequest struct {
	Model         string              `json:"model"`
	Normalized    bool                `json:"normalized,omitempty"`
	EmbeddingType EmbeddingType       `json:"embedding_type,omitempty"`
	Input         []map[string]string `json:"input"`
}

type EmbeddingResponse

type EmbeddingResponse struct {
	Model  string `json:"model"`
	Object string `json:"object"`
	Usage  struct {
		TotalTokens  int `json:"total_tokens"`
		PromptTokens int `json:"prompt_tokens"`
	}
	Data []struct {
		Object    string    `json:"object"`
		Index     int       `json:"index"`
		Embedding []float32 `json:"embedding"` // TODO what about other embedding types - see cohere for example
	}
}

type EmbeddingType

type EmbeddingType string

type JinaEmbeddingFunction

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

func NewJinaEmbeddingFunction

func NewJinaEmbeddingFunction(opts ...Option) (*JinaEmbeddingFunction, error)

func (*JinaEmbeddingFunction) EmbedDocuments

func (e *JinaEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]*types.Embedding, error)

func (*JinaEmbeddingFunction) EmbedQuery

func (e *JinaEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (*types.Embedding, error)

func (*JinaEmbeddingFunction) EmbedRecords

func (e *JinaEmbeddingFunction) EmbedRecords(ctx context.Context, records []*types.Record, force bool) error

type Option

type Option func(c *JinaEmbeddingFunction) error

func WithAPIKey

func WithAPIKey(apiKey string) Option

func WithEmbeddingEndpoint

func WithEmbeddingEndpoint(endpoint string) Option

func WithEmbeddingType

func WithEmbeddingType(embeddingType EmbeddingType) Option

WithEmbeddingType sets the type of the embedding to be returned by Jina. The default is float. Right now no other options are supported

func WithEnvAPIKey

func WithEnvAPIKey() Option

func WithModel

func WithModel(model types.EmbeddingModel) Option

func WithNormalized

func WithNormalized(normalized bool) Option

WithNormalized sets the flag to indicate to Jina whether to normalize (L2 norm) the output embeddings or not. Defaults to true

Jump to

Keyboard shortcuts

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