client

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatCompletionChoice

type ChatCompletionChoice struct {
	FinishedReason string                `json:"finish_reason"`
	Index          int                   `json:"index"`
	Message        ChatCompletionMessage `json:"message"`
}

type ChatCompletionMessage

type ChatCompletionMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type ChatCompletionParams

type ChatCompletionParams struct {
	Model    string                  `json:"model"`
	Messages []ChatCompletionMessage `json:"messages"`
}

type ChatCompletionResult

type ChatCompletionResult struct {
	Choices []ChatCompletionChoice `json:"choices"`
}

type Client

type Client interface {
	GenerateChatCompletion(ctx context.Context, params *ChatCompletionParams) (*ChatCompletionResult, error)
}

Client implements the OpenAI API client with minimal functionality

func New

func New(o ...Option) Client

New creates a new OpenAI API client

type Error

type Error struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

func (Error) Error

func (e Error) Error() string

type ErrorResponse

type ErrorResponse struct {
	Error Error `json:"error"`
}

type Option

type Option func(*client)

func WithAPIKey

func WithAPIKey(apiKey string) Option

func WithBaseURL

func WithBaseURL(baseURL string) Option

func WithOrgID

func WithOrgID(orgID string) Option

Jump to

Keyboard shortcuts

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