Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToMatrix ¶
func ConvertToMatrix(response *CreateEmbeddingResponse) [][]float32
Types ¶
type CreateEmbeddingRequest ¶
type CreateEmbeddingRequest struct {
Model string `json:"model"`
User string `json:"user"`
Input *Input `json:"input"`
Dimensions *int `json:"dimensions,omitempty"`
}
func (*CreateEmbeddingRequest) JSON ¶
func (c *CreateEmbeddingRequest) JSON() (string, error)
func (*CreateEmbeddingRequest) String ¶
func (c *CreateEmbeddingRequest) String() string
type CreateEmbeddingResponse ¶
type CreateEmbeddingResponse struct {
Object string `json:"object"`
Data []EmbeddingData `json:"data"`
Model string `json:"model"`
Usage Usage `json:"usage"`
}
func (*CreateEmbeddingResponse) String ¶
func (c *CreateEmbeddingResponse) String() string
type EmbeddingData ¶
type EmbeddingModel ¶
type EmbeddingModel string
const ( ModelContextVar = "model" DimensionsContextVar = "dimensions" TextEmbeddingAda002 EmbeddingModel = "text-embedding-ada-002" TextEmbedding3Small EmbeddingModel = "text-embedding-3-small" TextEmbedding3Large EmbeddingModel = "text-embedding-3-large" )
type Input ¶
type Input struct {
Text string `json:"-"`
Texts []string `json:"-"`
Integers []int `json:"-"`
ListOfListOfIntegers [][]int `json:"-"`
}
func (*Input) MarshalJSON ¶
type OpenAIClient ¶
type OpenAIClient struct {
BaseURL string
APIKey string
OrgID string
Client *http.Client
Model string
Dimensions *int
User string
}
func NewOpenAIClient ¶
func NewOpenAIClient(apiKey string, opts ...Option) (*OpenAIClient, error)
func (*OpenAIClient) CreateEmbedding ¶
func (c *OpenAIClient) CreateEmbedding(ctx context.Context, req *CreateEmbeddingRequest) (*CreateEmbeddingResponse, error)
type OpenAIEmbeddingFunction ¶
type OpenAIEmbeddingFunction struct {
// contains filtered or unexported fields
}
func NewOpenAIEmbeddingFunction ¶
func NewOpenAIEmbeddingFunction(apiKey string, opts ...Option) (*OpenAIEmbeddingFunction, error)
func (*OpenAIEmbeddingFunction) EmbedDocuments ¶
func (e *OpenAIEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]embeddings.Embedding, error)
func (*OpenAIEmbeddingFunction) EmbedQuery ¶
func (e *OpenAIEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (embeddings.Embedding, error)
type Option ¶
type Option func(c *OpenAIClient) error
Option is a function type that can be used to modify the client.
func WithBaseURL ¶
func WithDimensions ¶
func WithModel ¶
func WithModel(model EmbeddingModel) Option
WithModel is an option for setting the model to use. Must be one of: text-embedding-ada-002, text-embedding-3-small, text-embedding-3-large
func WithOpenAIOrganizationID ¶
WithOpenAIOrganizationID is an option for setting the OpenAI org id.
func WithOpenAIUser ¶ added in v0.2.3
WithOpenAIUser is an option for setting the OpenAI user. The user is passed with every request to OpenAI. It serves for auditing purposes. If not set the user defaults to ChromaGo client.
Click to show internal directories.
Click to hide internal directories.