chat

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachFile added in v0.5.0

func AttachFile(path string) (string, error)

AttachFile function converts markdown like text from text file data

func OutputHistory added in v0.4.0

func OutputHistory(r io.Reader, w io.Writer, userName, assistantName string) error

OutputHistory function converts markdown like text data from history data.

Types

type ChatContext

type ChatContext struct {
	*gpt.GPTContext
	// contains filtered or unexported fields
}

ChatContext is context data for chat

func New

func New(apiKey, cacheDir string, logger *zerolog.Logger, preparePath, savePath string) (*ChatContext, error)

New function create new ChatContext instance.

func (*ChatContext) AppendAssistantMessages added in v0.5.0

func (cctx *ChatContext) AppendAssistantMessages(msgs []string) error

AppendAssistantMessages method adds assistant messages.

func (*ChatContext) AppendUserMessages added in v0.5.0

func (cctx *ChatContext) AppendUserMessages(msgs []string) error

AppendUserMessages method adds user messages.

func (*ChatContext) Interactive

func (cctx *ChatContext) Interactive(ctx context.Context, w io.Writer) error

Interactive method is chatting in interactive mode (stream access).

func (*ChatContext) InteractiveMulti added in v0.6.0

func (cctx *ChatContext) InteractiveMulti(ctx context.Context, w io.Writer) error

InteractiveMulti method is chatting in interactive mode with multiline editing (stream access).

func (*ChatContext) Request

func (cctx *ChatContext) Request(ctx context.Context, rest bool, msgs []string, w io.Writer) error

Request requesta OpenAI Chat completion, and returns response message.

func (*ChatContext) Save added in v0.3.0

func (cctx *ChatContext) Save() error

Save method saves openai.ChatCompletionRequest data.

func (*ChatContext) SavePath added in v0.3.0

func (cctx *ChatContext) SavePath() string

SavePath method return Path of saving chat data.

Jump to

Keyboard shortcuts

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