openai

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package openai implements stream.Stream for OpenAI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*openai.Client
}

Client is the openai client.

func New

func New(config Config) *Client

New creates a new Client with the given Config.

func (*Client) Request

func (c *Client) Request(ctx context.Context, request proto.Request) stream.Stream

Request makes a new request and returns a stream.

type Config

type Config struct {
	AuthToken  string
	BaseURL    string
	HTTPClient interface {
		Do(*http.Request) (*http.Response, error)
	}
	APIType string
}

Config represents the configuration for the OpenAI API client.

func DefaultConfig

func DefaultConfig(authToken string) Config

DefaultConfig returns the default configuration for the OpenAI API client.

type Stream

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

Stream openai stream.

func (*Stream) CallTools

func (s *Stream) CallTools() []proto.ToolCallStatus

CallTools implements stream.Stream.

func (*Stream) Close

func (s *Stream) Close() error

Close implements stream.Stream.

func (*Stream) Current

func (s *Stream) Current() (proto.Chunk, error)

Current implements stream.Stream.

func (*Stream) Err

func (s *Stream) Err() error

Err implements stream.Stream.

func (*Stream) Messages

func (s *Stream) Messages() []proto.Message

Messages implements stream.Stream.

func (*Stream) Next

func (s *Stream) Next() bool

Next implements stream.Stream.

Jump to

Keyboard shortcuts

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