message

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	MessageID int64  `json:"message_id" db:"message_id"`
	SessionID int64  `json:"session_id" db:"session_id"`
	Role      string `json:"role" db:"role"`
	// Name optionally identifies the producer of this message (e.g. an agent name).
	Name    string `json:"name" db:"name"`
	Content string `json:"content" db:"content"`
	// Parts holds multi-modal content parts (text, images, etc.) serialized as JSON.
	Parts Parts `json:"parts" db:"parts"`
	// ReasoningContent stores the model's chain-of-thought output when provided.
	ReasoningContent string    `json:"reasoning_content" db:"reasoning_content"`
	ToolCalls        ToolCalls `json:"tool_calls" db:"tool_calls"`
	// ToolCallID links a tool-role message back to the assistant's ToolCall.ID it responds to.
	ToolCallID string `json:"tool_call_id" db:"tool_call_id"`
	// PromptTokens is the number of input tokens consumed by the LLM call that produced this message.
	PromptTokens int64 `json:"prompt_tokens" db:"prompt_tokens"`
	// CompletionTokens is the number of output tokens generated by the LLM call.
	CompletionTokens int64 `json:"completion_tokens" db:"completion_tokens"`
	// TotalTokens is the sum of PromptTokens and CompletionTokens.
	TotalTokens int64 `json:"total_tokens" db:"total_tokens"`
	CreatedAt   int64 `json:"created_at" db:"created_at"`
	UpdatedAt   int64 `json:"updated_at" db:"updated_at"`
	// CompactedAt is set when the message has been archived by a CompactMessages call.
	// A non-zero value means the message is compacted and no longer part of the active history.
	CompactedAt int64 `json:"compacted_at" db:"compacted_at"`
	DeletedAt   int64 `json:"deleted_at" db:"deleted_at"`
}

Message represents a persisted conversation message.

func FromModel

func FromModel(m model.Message) *Message

FromModel creates a Message from a model.Message, ready for persistence. MessageID and timestamp fields must be set by the caller before saving.

func (*Message) ToModel

func (m *Message) ToModel() model.Message

ToModel converts a persisted Message to a model.Message for LLM consumption.

type Parts added in v0.0.5

type Parts []model.ContentPart

Parts is a slice of ContentPart that serializes to/from JSON for database storage.

func (*Parts) Scan added in v0.0.5

func (p *Parts) Scan(src any) error

Scan implements sql.Scanner so Parts can be read from the database from a JSON string.

func (Parts) Value added in v0.0.5

func (p Parts) Value() (driver.Value, error)

Value implements driver.Valuer so Parts can be written to the database as a JSON string.

type ToolCall

type ToolCall struct {
	// ID is the unique identifier of this tool call, matching model.ToolCall.ID.
	ID        string `json:"id" db:"id"`
	Name      string `json:"name" db:"name"`
	Arguments string `json:"arguments" db:"arguments"`
}

ToolCall represents a persisted tool call within an assistant message.

type ToolCalls

type ToolCalls []ToolCall

ToolCalls is a slice of ToolCall that serializes to/from JSON for database storage.

func (*ToolCalls) Scan

func (tl *ToolCalls) Scan(src any) error

Scan implements sql.Scanner so ToolCallList can be read from the database from a JSON string.

func (ToolCalls) Value

func (tl ToolCalls) Value() (driver.Value, error)

Value implements driver.Valuer so ToolCallList can be written to the database as a JSON string.

Jump to

Keyboard shortcuts

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