chat

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChatCompletionsStream

func ChatCompletionsStream(actionSub chan ChatAction, profile config.Profile, messages []ChatMessage) tea.Cmd

func NewAzureChatClient

func NewAzureChatClient(config config.AzureConfig) (*azopenai.Client, error)

func NewOpenAIChatClient

func NewOpenAIChatClient(config config.OpenAIConfig) (*azopenai.Client, error)

func SendMessage

func SendMessage(actionSub chan ChatAction, newMessage string) tea.Cmd

func WaitForChatAction

func WaitForChatAction(actionSub chan ChatAction) tea.Cmd

Types

type ActionStatus

type ActionStatus = string
const (
	SentMessage    ActionStatus = "sendMessage"
	StreamStarted  ActionStatus = "streamStarted"
	Streaming      ActionStatus = "streaming"
	StreamFinished ActionStatus = "streamFinished"
	Error          ActionStatus = "error"
)

type ChatAction

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

type ChatMessage

type ChatMessage struct {
	Role      essentials.ChatRole
	CreatedAt time.Time
	Message   string
}

type ChatModel

type ChatModel struct {
	Profile            config.Profile
	MainView           viewport.Model
	InputTextarea      textarea.Model
	HelpView           help.Model
	MarkdownRender     glamour.TermRenderer
	Messages           []ChatMessage
	ActionSub          chan ChatAction
	Streaming          bool
	StreamingMessage   string
	StreamingStartedAt time.Time
}

func NewChatModel

func NewChatModel(profile config.Profile) (*ChatModel, error)

func (ChatModel) Divider

func (m ChatModel) Divider(topMargin bool, bottomMargin bool) string

func (ChatModel) Help

func (m ChatModel) Help() string

func (ChatModel) Init

func (m ChatModel) Init() tea.Cmd

func (ChatModel) MainViewContent

func (m ChatModel) MainViewContent() string

func (ChatModel) Message

func (m ChatModel) Message(message ChatMessage) string

func (ChatModel) MessagesHistory

func (m ChatModel) MessagesHistory() string

func (ChatModel) Update

func (m ChatModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (ChatModel) View

func (m ChatModel) View() string

type HelpKeyMap

type HelpKeyMap struct {
	ScrollUp   key.Binding
	ScrollDown key.Binding
	Send       key.Binding
	Quit       key.Binding
}

func (HelpKeyMap) FullHelp

func (k HelpKeyMap) FullHelp() [][]key.Binding

func (HelpKeyMap) ShortHelp

func (k HelpKeyMap) ShortHelp() []key.Binding

Jump to

Keyboard shortcuts

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