morph

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIKeyEnvVar = "MORPH_API_KEY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateEmbeddingRequest

type CreateEmbeddingRequest struct {
	Model          string   `json:"model"`
	Input          []string `json:"input"`
	EncodingFormat string   `json:"encoding_format,omitempty"`
}

type CreateEmbeddingResponse

type CreateEmbeddingResponse struct {
	Object string          `json:"object"`
	Data   []EmbeddingData `json:"data"`
	Model  string          `json:"model"`
	Usage  Usage           `json:"usage"`
}

type EmbeddingData

type EmbeddingData struct {
	Object    string    `json:"object"`
	Index     int       `json:"index"`
	Embedding []float32 `json:"embedding"`
}

type MorphClient

type MorphClient struct {
	BaseURL      string            `default:"https://api.morphllm.com/v1/"`
	APIKey       embeddings.Secret `json:"-" validate:"required"`
	APIKeyEnvVar string            `json:"-"`
	Client       *http.Client      `json:"-"`
	Model        string            `default:"morph-embedding-v2"`
	Insecure     bool
}

func NewMorphClient

func NewMorphClient(apiKey string, opts ...Option) (*MorphClient, error)

func (*MorphClient) CreateEmbedding

type MorphEmbeddingFunction

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

func NewMorphEmbeddingFunction

func NewMorphEmbeddingFunction(opts ...Option) (*MorphEmbeddingFunction, error)

func (*MorphEmbeddingFunction) DefaultSpace

func (*MorphEmbeddingFunction) EmbedDocuments

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

func (*MorphEmbeddingFunction) EmbedQuery

func (e *MorphEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (embeddings.Embedding, error)

func (*MorphEmbeddingFunction) GetConfig

func (*MorphEmbeddingFunction) Name

func (e *MorphEmbeddingFunction) Name() string

func (*MorphEmbeddingFunction) SupportedSpaces

func (e *MorphEmbeddingFunction) SupportedSpaces() []embeddings.DistanceMetric

type Option

type Option func(c *MorphClient) error

func WithAPIKey

func WithAPIKey(apiKey string) Option

func WithAPIKeyFromEnvVar

func WithAPIKeyFromEnvVar(envVar string) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithEnvAPIKey

func WithEnvAPIKey() Option

func WithInsecure

func WithInsecure() Option

func WithModel

func WithModel(model string) Option

type Usage

type Usage struct {
	PromptTokens int `json:"prompt_tokens"`
	TotalTokens  int `json:"total_tokens"`
}

Jump to

Keyboard shortcuts

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