mistral

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 (
	DefaultEmbeddingModel             = NomicEmbedTextV1
	ModelContextVar                   = "model"
	DimensionalityContextVar          = "dimensionality"
	TaskTypeContextVar                = "task_type"
	APIKeyEnvVar                      = "NOMIC_API_KEY"
	DefaultBaseURL                    = "https://api-atlas.nomic.ai/v1/embedding"
	TextEmbeddingsEndpoint            = "/text"
	DefaultMaxBatchSize               = 100
	TaskTypeSearchQuery      TaskType = "search_query" //
	TaskTypeSearchDocument   TaskType = "search_document"
	TaskTypeClustering       TaskType = "clustering"
	TaskTypeClassification   TaskType = "classification"
	NomicEmbedTextV1                  = "nomic-embed-text-v1"
	NomicEmbedTextV15                 = "nomic-embed-text-v1.5"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	DefaultModel             string
	Client                   *http.Client
	DefaultContext           *context.Context
	MaxBatchSize             int
	EmbeddingEndpoint        string
	DefaultHeaders           map[string]string
	DefaultTaskType          *TaskType
	DefaultDimensionality    *int
	BaseURL                  string
	EmbeddingsEndpointSuffix string
	// contains filtered or unexported fields
}

func NewNomicClient

func NewNomicClient(opts ...Option) (*Client, error)

func (*Client) CreateEmbedding

func (c *Client) CreateEmbedding(ctx context.Context, req CreateEmbeddingRequest) ([]*types.Embedding, error)

type CreateEmbeddingRequest

type CreateEmbeddingRequest struct {
	Model          string    `json:"model"`
	Texts          []string  `json:"texts"`
	TaskType       *TaskType `json:"task_type,omitempty"`
	Dimensionality *int      `json:"dimensionality,omitempty"`
}

func (*CreateEmbeddingRequest) JSON

func (c *CreateEmbeddingRequest) JSON() (string, error)

type CreateEmbeddingResponse

type CreateEmbeddingResponse struct {
	Usage      map[string]any `json:"usage,omitempty"`
	Embeddings [][]float32    `json:"embeddings"`
}

type NomicEmbeddingFunction

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

func NewNomicEmbeddingFunction

func NewNomicEmbeddingFunction(opts ...Option) (*NomicEmbeddingFunction, error)

func (*NomicEmbeddingFunction) EmbedDocuments

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

func (*NomicEmbeddingFunction) EmbedQuery

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

func (*NomicEmbeddingFunction) EmbedRecords

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

type Option

type Option func(p *Client) error

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey sets the API key for the client

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL sets the base URL for the client

func WithDefaultModel

func WithDefaultModel(model string) Option

WithDefaultModel sets the default model for the client

func WithEnvAPIKey

func WithEnvAPIKey() Option

WithEnvAPIKey sets the API key for the client from the environment variable GOOGLE_API_KEY

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets the generative AI client for the client

func WithMaxBatchSize

func WithMaxBatchSize(maxBatchSize int) Option

WithMaxBatchSize sets the max batch size for the client - this acts as a limit for the number of embeddings that can be sent in a single request

func WithTextEmbeddings

func WithTextEmbeddings() Option

WithTextEmbeddings sets the endpoint to text embeddings

type TaskType

type TaskType string

Jump to

Keyboard shortcuts

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