openaiclient

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback interface {
	// OnLLMNewToken Runs on new LLM token. Only available when streaming is enabled
	OnLLMNewToken(str string)
}

Callback handlers for streaming. Only works with LLMs that support streaming.

type ChatMessage

type ChatMessage struct {
	// The role of the author of this message. One of system, user, or assistant.
	Role string `json:"role"`
	// The content of the message.
	Content string `json:"content"`
	// The name of the author of this message. May contain a-z, A-Z, 0-9, and underscores,
	// with a maximum length of 64 characters.
	Name string `json:"name,omitempty"`
}

ChatMessage is a message in a chat request.

type ChatRequest

type ChatRequest struct {
	Model       string  `json:"models"`
	Prompt      string  `json:"prompt"`
	Temperature float64 `json:"temperature,omitempty"`
}

ChatRequest is a request to create an embedding.

type Client

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

func New

func New(dailTarget, model string, c container.Container, cb Callback) *Client

New returns a new OpenAI client.

func (*Client) CreateChatWithStream

func (c *Client) CreateChatWithStream(ctx context.Context, r *ChatRequest) (string, error)

CreateChatWithStream creates chat request

Jump to

Keyboard shortcuts

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