openai

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package openai provides an implementation of the Provider interface for OpenAI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOpenAIProvider

func NewOpenAIProvider(config *core.ProviderConfig) (core.Provider, error)

NewOpenAIProvider creates a new OpenAI provider

Types

type OpenAIProvider

type OpenAIProvider struct {
	*core.BaseProvider
	// contains filtered or unexported fields
}

OpenAIProvider is an implementation of the Provider interface for OpenAI

func (*OpenAIProvider) ChatCompletion

ChatCompletion generates a chat completion

func (*OpenAIProvider) Close

func (p *OpenAIProvider) Close() error

Close closes the provider and releases any resources

func (*OpenAIProvider) CountTokens

func (p *OpenAIProvider) CountTokens(ctx context.Context, text string, modelID string) (int, error)

CountTokens counts the number of tokens in a text

func (*OpenAIProvider) CreateEmbedding

func (p *OpenAIProvider) CreateEmbedding(ctx context.Context, request *core.EmbeddingRequest) (*core.EmbeddingResponse, error)

CreateEmbedding creates an embedding

func (*OpenAIProvider) GetModels

func (p *OpenAIProvider) GetModels(ctx context.Context) ([]core.ModelInfo, error)

GetModels returns a list of available models

func (*OpenAIProvider) StreamingChatCompletion

func (p *OpenAIProvider) StreamingChatCompletion(ctx context.Context, request *core.ChatCompletionRequest, callback func(response *core.ChatCompletionResponse) error) error

StreamingChatCompletion generates a streaming chat completion

func (*OpenAIProvider) TextCompletion

TextCompletion generates a text completion

Jump to

Keyboard shortcuts

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