chat

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: Apache-2.0 Imports: 3 Imported by: 6

Documentation

Overview

Package chat contains a client for Open AI's ChatGPT APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	Message      *Message `json:"message,omitempty"`
	Index        int      `json:"index,omitempty"`
	LogProbs     int      `json:"logprobs,omitempty"`
	FinishReason string   `json:"finish_reason,omitempty"`
}

type Client

type Client struct {

	// CreateCompletionsEndpoint allows overriding the default API endpoint.
	// Set this field before using the client.
	CreateCompletionEndpoint string
	// contains filtered or unexported fields
}

Client is a client to communicate with Open AI's ChatGPT APIs.

func NewClient

func NewClient(session *openai.Session, model string) *Client

NewClient creates a new default client that uses the given session and defaults to the given model.

func (*Client) CreateCompletion

type CreateCompletionParams

type CreateCompletionParams struct {
	Model string `json:"model,omitempty"`

	Messages []*Message `json:"messages,omitempty"`
	Stop     []string   `json:"stop,omitempty"`
	Stream   bool       `json:"stream,omitempty"`

	N           int     `json:"n,omitempty"`
	TopP        float64 `json:"top_p,omitempty"`
	Temperature float64 `json:"temperature,omitempty"`
	MaxTokens   int     `json:"max_tokens,omitempty"`

	PresencePenalty  float64 `json:"presence_penalty,omitempty"`
	FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`

	User string `json:"user,omitempty"`
}

type CreateCompletionResponse

type CreateCompletionResponse struct {
	ID        string    `json:"id,omitempty"`
	Object    string    `json:"object,omitempty"`
	CreatedAt int64     `json:"created_at,omitempty"`
	Choices   []*Choice `json:"choices,omitempty"`

	Usage *openai.Usage `json:"usage,omitempty"`
}

type CreateCompletionStreamingResponse added in v1.0.3

type CreateCompletionStreamingResponse struct {
	ID        string             `json:"id,omitempty"`
	Object    string             `json:"object,omitempty"`
	CreatedAt int64              `json:"created_at,omitempty"`
	Choices   []*StreamingChoice `json:"choices,omitempty"`
}

type Message

type Message struct {
	Role    string `json:"role,omitempty"`
	Content string `json:"content,omitempty"`
	Name    string `json:"name,omitempty"`
}

type StreamingChoice added in v1.0.3

type StreamingChoice struct {
	Delta        *Message `json:"delta,omitempty"`
	Index        int      `json:"index,omitempty"`
	LogProbs     int      `json:"logprobs,omitempty"`
	FinishReason string   `json:"finish_reason,omitempty"`
}

type StreamingClient added in v1.0.3

type StreamingClient struct {

	// CreateCompletionsEndpoint allows overriding the default API endpoint.
	// Set this field before using the client.
	CreateCompletionEndpoint string
	// contains filtered or unexported fields
}

StreamingClient is a client to communicate with Open AI's ChatGPT APIs.

func NewStreamingClient added in v1.0.3

func NewStreamingClient(session *openai.Session, model string) *StreamingClient

NewStreamingClient creates a new default streaming client that uses the given session and defaults to the given model.

func (*StreamingClient) CreateCompletion added in v1.0.3

Jump to

Keyboard shortcuts

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