chat

package
v0.0.0-...-b8911e7 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SystemMessage = openai.ChatMessage{
	Role:    openai.ChatRoleSystem,
	Content: "You are HAL, a powerful code and text editor controlled by natural language. Answer as concisely as possible.",
}

Functions

func Send

func Send(client *openai.Client, chatHistory []openai.ChatMessage, text string) tea.Cmd

Types

type FinishedMsg

type FinishedMsg struct {
	Err     error
	Buffer  []byte
	History []openai.ChatMessage
	Tokens  int
}

type SearchResult

type SearchResult struct {
	// The message that matched the search query.
	Message *openai.ChatMessage

	// MessageIndex is the index of the message in the chat history.
	MessageIndex int

	// MatchStart is the index of the start of the match in the message.
	StartIndex int

	// MatchEnd is the index of the end of the match in the message.
	EndIndex int
}

SearchResult is a search result for a chat thread.

type Thread

type Thread struct {
	// Name (title) of the thread.
	Name string `json:"name"`

	// Summary (description) of the thread.
	Summary string `json:"summary"`

	// Created is the date the thread was created.
	Created time.Time `json:"date"`

	// The prompt is the initial text that the model will generate from.
	// This is the text that the user will see when they first open the
	// chat window.
	Prompt string `json:"prompt"`

	// The chat history is the list of messages that have been sent and
	// received in the chat session.
	ChatHistory []openai.ChatMessage `json:"chat_history"`

	// Tokens is the last reported number of tokens used in the chat session.
	Tokens int `json:"tokens"`
}

Thread is a "chat thread" that is used to store the chat history and metadata for a chat session. It implements the list.Item interface so that it can shown in a list in the UI.

func (*Thread) Description

func (ct *Thread) Description() string

func (*Thread) FilterValue

func (ct *Thread) FilterValue() string

func (*Thread) Search

func (ct *Thread) Search(ctx context.Context, query string) ([]*SearchResult, error)

Search retruns the messages that match the search query. Searching happens locally on the host.

TODO: consider returning index information in the search results so that we can highlight the matches in the UI.

func (*Thread) Summarize

func (ct *Thread) Summarize(ctx context.Context, client *openai.Client) (string, error)

Summarize returns a summrized version of the chat history.

func (*Thread) Title

func (ct *Thread) Title() string

Implement the list.Item interface.

type Threads

type Threads []*Thread

Threads is a collection of chat threads.

func (Threads) Len

func (cts Threads) Len() int

Implement the sort.Interface interface.

func (Threads) Less

func (cts Threads) Less(i, j int) bool

func (Threads) ListItems

func (cts Threads) ListItems() []list.Item

ListItems returns a list of list.Item's from the Threads.

func (Threads) Swap

func (cts Threads) Swap(i, j int)

Jump to

Keyboard shortcuts

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