openai

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxFunctionCalls   = 10
	OpenAIMaxImageSize = 20 * 1024 * 1024 // 20 MB
)

Variables

View Source
var ErrStreamingTimeout = errors.New("timeout streaming")

Functions

This section is empty.

Types

type Config

type Config struct {
	APIKey              string        `json:"apiKey"`
	APIURL              string        `json:"apiURL"`
	OrgID               string        `json:"orgID"`
	DefaultModel        string        `json:"defaultModel"`
	InputTokenLimit     int           `json:"inputTokenLimit"`
	OutputTokenLimit    int           `json:"outputTokenLimit"`
	StreamingTimeout    time.Duration `json:"streamingTimeout"`
	SendUserID          bool          `json:"sendUserID"`
	EmbeddingModel      string        `json:"embeddingModel"`
	EmbeddingDimentions int           `json:"embeddingDimensions"`
}

type OpenAI

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

func New

func New(config Config, httpClient *http.Client) *OpenAI

func NewAzure

func NewAzure(config Config, httpClient *http.Client) *OpenAI

func NewCompatible

func NewCompatible(config Config, httpClient *http.Client) *OpenAI

func NewCompatibleEmbeddings

func NewCompatibleEmbeddings(config Config, httpClient *http.Client) *OpenAI

NewCompatibleEmbeddings creates a new OpenAI client configured only for embeddings functionality

func NewEmbeddings

func NewEmbeddings(config Config, httpClient *http.Client) *OpenAI

NewEmbeddings creates a new OpenAI client configured only for embeddings functionality

func (*OpenAI) BatchCreateEmbeddings

func (s *OpenAI) BatchCreateEmbeddings(ctx context.Context, texts []string) ([][]float32, error)

BatchCreateEmbeddings generates embeddings for multiple texts in a single API call

func (*OpenAI) ChatCompletion

func (s *OpenAI) ChatCompletion(request llm.CompletionRequest, opts ...llm.LanguageModelOption) (*llm.TextStreamResult, error)

func (*OpenAI) ChatCompletionNoStream

func (s *OpenAI) ChatCompletionNoStream(request llm.CompletionRequest, opts ...llm.LanguageModelOption) (string, error)

func (*OpenAI) CountTokens

func (s *OpenAI) CountTokens(text string) int

func (*OpenAI) CreateEmbedding

func (s *OpenAI) CreateEmbedding(ctx context.Context, text string) ([]float32, error)

func (*OpenAI) Dimensions

func (s *OpenAI) Dimensions() int

func (*OpenAI) GenerateImage

func (s *OpenAI) GenerateImage(prompt string) (image.Image, error)

func (*OpenAI) GetDefaultConfig

func (s *OpenAI) GetDefaultConfig() llm.LanguageModelConfig

func (*OpenAI) InputTokenLimit

func (s *OpenAI) InputTokenLimit() int

func (*OpenAI) Transcribe

func (s *OpenAI) Transcribe(file io.Reader) (*subtitles.Subtitles, error)

type ToolBufferElement

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

Jump to

Keyboard shortcuts

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