model

package
v0.0.0-...-e32bf32 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content struct {
	Role Role   `json:"role"`
	Text string `json:"text"`
}

type History

type History struct {
	Contents []*Content `json:"contents"`
}

func NewHistory

func NewHistory() *History

func (*History) Append

func (h *History) Append(role Role, text string) *History

func (*History) ToGeminiContents

func (h *History) ToGeminiContents() (genai.Text, []*genai.Content)

Returns a tuple of the user message and all historical messages that is ready to be consumed by Gemini's genai package.

type Message

type Message struct {
	MessageID int64  `json:"message_id"`
	CreatedAt int64  `json:"created_at"`
	ChatID    int64  `json:"chat_id"`
	SenderID  int64  `json:"sender_id"`
	ReplyID   *int64 `json:"reply_id,omitempty"`
	Content   string `json:"content"`
}

func NewMessage

func NewMessage(
	messageID, unixTimestamp, chatID, userID int64,
	messageReplied *gotgbot.Message,
	content string,
) *Message

type Model

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

func New

func New(db *database.Database) *Model

func (*Model) GetReplies

func (m *Model) GetReplies(ctx context.Context, msgID int64) ([]Message, error)

Returns all replies of the given message.

func (*Model) StoreMessages

func (m *Model) StoreMessages(ctx context.Context, msgs []Message) error

Stores messages into the database, returning the first error encountered.

type Role

type Role string
const (
	RoleUser  Role = "user"
	RoleModel Role = "model"
)

Jump to

Keyboard shortcuts

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