embedding

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Overview

Package embedding contains a client for Open AI's Embeddings APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// CreateEndpoint allows overriding the default API endpoint.
	// Set this field before using the client.
	CreateEndpoint string
	// contains filtered or unexported fields
}

Client is a client to communicate with Open AI's Embeddings APIs.

func NewClient

func NewClient(session *openai.Session, model string) *Client

NewClient creates a new default client that uses the given session and defaults to the given model.

func (*Client) Create

func (c *Client) Create(ctx context.Context, p *CreateParams) (*CreateResponse, error)

type CreateParams

type CreateParams struct {
	Model string `json:"model,omitempty"`

	Input []string `json:"input,omitempty"`
	User  string   `json:"user,omitempty"`
}

type CreateResponse

type CreateResponse struct {
	Object string  `json:"object,omitempty"`
	Data   []*Data `json:"data,omitempty"`
	Model  string  `json:"model,omitempty"`

	Usage *openai.Usage `json:"usage,omitempty"`
}

type Data

type Data struct {
	Object    string    `json:"object,omitempty"`
	Embedding []float64 `json:"embedding,omitempty"`
	Index     int       `json:"index,omitempty"`
}

Jump to

Keyboard shortcuts

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