openai

package
v0.0.0-...-919d8db Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the OpenAI client to implement agent.LLMClient

func New

func New(apiKey, model string) *Client

New creates a new Client

func NewWithOptions

func NewWithOptions(model string, opts ...option.RequestOption) *Client

NewWithOptions creates a new Client with custom options

func (*Client) CountTokens

func (c *Client) CountTokens(ctx context.Context, req agent.MessagesRequest) (int, error)

CountTokens estimates the number of tokens in a request. OpenAI doesn't provide a direct token counting API, so this is a rough estimation. A more accurate implementation would use tiktoken or similar tokenizer.

func (*Client) CreateMessages

func (c *Client) CreateMessages(ctx context.Context, req agent.MessagesRequest, onUpdate func(agent.MessagesResponse)) (agent.MessagesResponse, error)

func (*Client) SetModel

func (c *Client) SetModel(model string)

SetModel sets the model for the client

Jump to

Keyboard shortcuts

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