Documentation
¶
Index ¶
- Constants
- func ContextWithModel(ctx context.Context, model string) context.Context
- type CreateEmbeddingRequest
- type CreateEmbeddingResponse
- type EmbeddingInputs
- type EmbeddingResult
- type EmbeddingTypeResult
- type Option
- func WithAPIKey(apiKey string) Option
- func WithAPIKeyFromEnvVar(envVar string) Option
- func WithBaseURL(baseURL string) Option
- func WithDimensions(dimensions int) Option
- func WithEnvAPIKey() Option
- func WithHTTPClient(client *http.Client) Option
- func WithInsecure() Option
- func WithModel(model embeddings.EmbeddingModel) Option
- type PerplexityClient
- type PerplexityEmbeddingFunction
- func (e *PerplexityEmbeddingFunction) DefaultSpace() embeddings.DistanceMetric
- func (e *PerplexityEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]embeddings.Embedding, error)
- func (e *PerplexityEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (embeddings.Embedding, error)
- func (e *PerplexityEmbeddingFunction) GetConfig() embeddings.EmbeddingFunctionConfig
- func (e *PerplexityEmbeddingFunction) Name() string
- func (e *PerplexityEmbeddingFunction) SupportedSpaces() []embeddings.DistanceMetric
- type UsageResult
Constants ¶
View Source
const ( APIKeyEnvVar = "PERPLEXITY_API_KEY" EncodingFormatBase64Int8 = "base64_int8" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CreateEmbeddingRequest ¶
type CreateEmbeddingRequest struct {
Model string `json:"model"`
Input *EmbeddingInputs `json:"input"`
Dimensions *int `json:"dimensions,omitempty"`
EncodingFormat string `json:"encoding_format"`
}
func (*CreateEmbeddingRequest) JSON ¶
func (c *CreateEmbeddingRequest) JSON() (string, error)
type CreateEmbeddingResponse ¶
type CreateEmbeddingResponse struct {
Object string `json:"object"`
Data []EmbeddingResult `json:"data"`
Model string `json:"model"`
Usage *UsageResult `json:"usage,omitempty"`
}
type EmbeddingInputs ¶
func (*EmbeddingInputs) MarshalJSON ¶
func (e *EmbeddingInputs) MarshalJSON() ([]byte, error)
type EmbeddingResult ¶
type EmbeddingResult struct {
Object string `json:"object"`
Embedding *EmbeddingTypeResult `json:"embedding"`
Index int `json:"index"`
}
type EmbeddingTypeResult ¶
type EmbeddingTypeResult struct {
Floats []float32
}
func (*EmbeddingTypeResult) UnmarshalJSON ¶
func (e *EmbeddingTypeResult) UnmarshalJSON(data []byte) error
type Option ¶
type Option func(p *PerplexityClient) error
func WithAPIKey ¶
func WithAPIKeyFromEnvVar ¶
WithAPIKeyFromEnvVar sets the API key for the client from a specified environment variable.
func WithBaseURL ¶
func WithDimensions ¶
func WithEnvAPIKey ¶
func WithEnvAPIKey() Option
func WithHTTPClient ¶
func WithInsecure ¶
func WithInsecure() Option
WithInsecure allows the client to connect to HTTP endpoints without TLS. This should only be used for local development or testing.
func WithModel ¶
func WithModel(model embeddings.EmbeddingModel) Option
type PerplexityClient ¶
type PerplexityClient struct {
APIKey embeddings.Secret `json:"-" validate:"required"`
// contains filtered or unexported fields
}
func NewPerplexityClient ¶
func NewPerplexityClient(opts ...Option) (*PerplexityClient, error)
func (*PerplexityClient) CreateEmbedding ¶
func (c *PerplexityClient) CreateEmbedding(ctx context.Context, req *CreateEmbeddingRequest) (*CreateEmbeddingResponse, error)
type PerplexityEmbeddingFunction ¶
type PerplexityEmbeddingFunction struct {
// contains filtered or unexported fields
}
func NewPerplexityEmbeddingFunction ¶
func NewPerplexityEmbeddingFunction(opts ...Option) (*PerplexityEmbeddingFunction, error)
func NewPerplexityEmbeddingFunctionFromConfig ¶
func NewPerplexityEmbeddingFunctionFromConfig(cfg embeddings.EmbeddingFunctionConfig) (*PerplexityEmbeddingFunction, error)
func (*PerplexityEmbeddingFunction) DefaultSpace ¶
func (e *PerplexityEmbeddingFunction) DefaultSpace() embeddings.DistanceMetric
func (*PerplexityEmbeddingFunction) EmbedDocuments ¶
func (e *PerplexityEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]embeddings.Embedding, error)
func (*PerplexityEmbeddingFunction) EmbedQuery ¶
func (e *PerplexityEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (embeddings.Embedding, error)
func (*PerplexityEmbeddingFunction) GetConfig ¶
func (e *PerplexityEmbeddingFunction) GetConfig() embeddings.EmbeddingFunctionConfig
func (*PerplexityEmbeddingFunction) Name ¶
func (e *PerplexityEmbeddingFunction) Name() string
func (*PerplexityEmbeddingFunction) SupportedSpaces ¶
func (e *PerplexityEmbeddingFunction) SupportedSpaces() []embeddings.DistanceMetric
type UsageResult ¶
Click to show internal directories.
Click to hide internal directories.