jina

package
v0.1.10-pre.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SmallModel = "jina-embeddings-v2-small-en"
	BaseModel  = "jina-embeddings-v2-base-en"
	LargeModel = "jina-embeddings-v2-large-en"
	APIBaseURL = "https://api.jina.ai/v1/embeddings"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddingRequest

type EmbeddingRequest struct {
	Input []string `json:"input"`
	Model string   `json:"model"`
}

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"`
	} `json:"usage"`
	Data []struct {
		Object    string    `json:"object"`
		Index     int       `json:"index"`
		Embedding []float32 `json:"embedding"`
	} `json:"data"`
}

type Jina

type Jina struct {
	Model         string
	InputText     []string
	StripNewLines bool
	BatchSize     int
	APIBaseURL    string
	APIKey        string
}

func NewJina

func NewJina(opts ...Option) (*Jina, error)

func (*Jina) CreateEmbedding

func (j *Jina) CreateEmbedding(ctx context.Context, texts []string) ([][]float32, error)

CreateEmbedding sends texts to the Jina API and retrieves their embeddings.

func (*Jina) EmbedDocuments

func (j *Jina) EmbedDocuments(ctx context.Context, texts []string) ([][]float32, error)

func (*Jina) EmbedQuery

func (j *Jina) EmbedQuery(ctx context.Context, text string) ([]float32, error)

type Option

type Option func(p *Jina)

Option is a function type that can be used to modify the client.

func WithAPIBaseURL

func WithAPIBaseURL(apiBaseURL string) Option

WithAPIBaseURL is an option for specifying the API base URL.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey is an option for specifying the API key.

func WithBatchSize

func WithBatchSize(batchSize int) Option

WithBatchSize is an option for specifying the batch size.

func WithModel

func WithModel(model string) Option

WithModel is an option for providing the model name to use.

func WithStripNewLines

func WithStripNewLines(stripNewLines bool) Option

WithStripNewLines is an option for specifying the should it strip new lines.

Jump to

Keyboard shortcuts

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