chat

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const AssistantRole = "assistant"
View Source
const SystemRole = "system"
View Source
const UserRole = "user"

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	Answer   message
	Question message
	Duration time.Duration
}

func NewChat

func NewChat(question string) *Chat

func (*Chat) AddAnswer

func (r *Chat) AddAnswer(answer string)

func (*Chat) AddQuestion

func (r *Chat) AddQuestion(question string)

func (*Chat) DurationSeconds

func (r *Chat) DurationSeconds() float64

func (*Chat) GetAnswer

func (r *Chat) GetAnswer() string

func (*Chat) GetQuestion

func (r *Chat) GetQuestion() string

func (*Chat) HasAnswer

func (r *Chat) HasAnswer() bool

type ChatHistory

type ChatHistory struct {
	Responses []Chat
}

func NewChatHistory

func NewChatHistory() ChatHistory

func (*ChatHistory) AddChat

func (c *ChatHistory) AddChat(chat Chat)

*

  • Adds a chat to the chat history.
  • The chat can can still be incomplete, but it must have at least a question.
  • The answer will be added later by the model.

func (*ChatHistory) Clear

func (c *ChatHistory) Clear()

func (*ChatHistory) LastAnswer

func (c *ChatHistory) LastAnswer() string

func (ChatHistory) LastChat

func (c ChatHistory) LastChat() (Chat, bool)

Returns the last chat in the chat history. If there are no responses, it returns false with empty Chat.

func (*ChatHistory) LastQuestion

func (c *ChatHistory) LastQuestion() string

func (*ChatHistory) Len

func (c *ChatHistory) Len() int

func (*ChatHistory) SetNewAnswerToLastChat

func (c *ChatHistory) SetNewAnswerToLastChat(answer string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳