message

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsTextAttachment

func ContainsTextAttachment(attachments []Attachment) bool

ContainsTextAttachment returns true if any of the attachments is a text attachment.

func PromptWithTextAttachments

func PromptWithTextAttachments(prompt string, attachments []Attachment) string

Types

type Attachment

type Attachment struct {
	FilePath string
	FileName string
	MimeType string
	Content  []byte
}

func (Attachment) IsImage

func (a Attachment) IsImage() bool

func (Attachment) IsMarkdown

func (a Attachment) IsMarkdown() bool

func (Attachment) IsText

func (a Attachment) IsText() bool

type BinaryContent

type BinaryContent struct {
	Path     string
	MIMEType string
	Data     []byte
}

func (BinaryContent) String

type ContentPart

type ContentPart interface {
	// contains filtered or unexported methods
}

type CreateMessageParams

type CreateMessageParams struct {
	Role             MessageRole
	Parts            []ContentPart
	Model            string
	Provider         string
	IsSummaryMessage bool
}

CreateMessageParams are the parameters for creating a new message.

type Finish

type Finish struct {
	Reason  FinishReason `json:"reason"`
	Time    int64        `json:"time"`
	Message string       `json:"message,omitempty"`
	Details string       `json:"details,omitempty"`
}

type FinishReason

type FinishReason string
const (
	FinishReasonEndTurn   FinishReason = "end_turn"
	FinishReasonMaxTokens FinishReason = "max_tokens"
	FinishReasonToolUse   FinishReason = "tool_use"
	FinishReasonCanceled  FinishReason = "canceled"
	FinishReasonError     FinishReason = "error"

	// Should never happen
	FinishReasonUnknown FinishReason = "unknown"
)

type ImageURLContent

type ImageURLContent struct {
	URL    string `json:"url"`
	Detail string `json:"detail,omitempty"`
}

func (ImageURLContent) String

func (iuc ImageURLContent) String() string

type Message

type Message struct {
	ID               string
	Role             MessageRole
	SessionID        string
	Parts            []ContentPart
	Model            string
	Provider         string
	CreatedAt        int64
	UpdatedAt        int64
	IsSummaryMessage bool
}

func (*Message) AddBinary

func (m *Message) AddBinary(mimeType string, data []byte)

func (*Message) AddFinish

func (m *Message) AddFinish(reason FinishReason, message, details string)

func (*Message) AddImageURL

func (m *Message) AddImageURL(url, detail string)

func (*Message) AddToolCall

func (m *Message) AddToolCall(tc ToolCall)

func (*Message) AddToolResult

func (m *Message) AddToolResult(tr ToolResult)

func (*Message) AppendContent

func (m *Message) AppendContent(delta string)

func (*Message) AppendReasoningContent

func (m *Message) AppendReasoningContent(delta string)

func (*Message) AppendReasoningSignature

func (m *Message) AppendReasoningSignature(signature string)

func (*Message) AppendThoughtSignature

func (m *Message) AppendThoughtSignature(signature string, toolCallID string)

func (*Message) AppendToolCallInput

func (m *Message) AppendToolCallInput(toolCallID string, inputDelta string)

func (*Message) BinaryContent

func (m *Message) BinaryContent() []BinaryContent

func (*Message) Clone

func (m *Message) Clone() Message

Clone returns a deep copy of the message with an independent Parts slice. This prevents race conditions when the message is modified concurrently.

func (*Message) Content

func (m *Message) Content() TextContent

func (*Message) FinishPart

func (m *Message) FinishPart() *Finish

func (*Message) FinishReason

func (m *Message) FinishReason() FinishReason

func (*Message) FinishThinking

func (m *Message) FinishThinking()

func (*Message) FinishToolCall

func (m *Message) FinishToolCall(toolCallID string)

func (*Message) ImageURLContent

func (m *Message) ImageURLContent() []ImageURLContent

func (*Message) IsFinished

func (m *Message) IsFinished() bool

func (*Message) IsThinking

func (m *Message) IsThinking() bool

func (*Message) ReasoningContent

func (m *Message) ReasoningContent() ReasoningContent

func (*Message) SetToolCalls

func (m *Message) SetToolCalls(tc []ToolCall)

func (*Message) SetToolResults

func (m *Message) SetToolResults(tr []ToolResult)

func (*Message) ThinkingDuration

func (m *Message) ThinkingDuration() time.Duration

func (*Message) ToolCalls

func (m *Message) ToolCalls() []ToolCall

func (*Message) ToolResults

func (m *Message) ToolResults() []ToolResult

type MessageRole

type MessageRole string
const (
	Assistant MessageRole = "assistant"
	User      MessageRole = "user"
	System    MessageRole = "system"
	Tool      MessageRole = "tool"
)

type ReasoningContent

type ReasoningContent struct {
	Thinking         string `json:"thinking"`
	Signature        string `json:"signature"`
	ThoughtSignature string `json:"thought_signature"` // Used for google
	ToolID           string `json:"tool_id"`           // Used for openrouter google models
	StartedAt        int64  `json:"started_at,omitempty"`
	FinishedAt       int64  `json:"finished_at,omitempty"`
}

func (ReasoningContent) String

func (tc ReasoningContent) String() string

type Service

type Service interface {
	pubsub.Subscriber[Message]
	Create(ctx context.Context, sessionID string, params CreateMessageParams) (Message, error)
	Update(ctx context.Context, message Message) error
	Get(ctx context.Context, id string) (Message, error)
	List(ctx context.Context, sessionID string) ([]Message, error)
	ListUserMessages(ctx context.Context, sessionID string) ([]Message, error)
	ListAllUserMessages(ctx context.Context) ([]Message, error)
	Delete(ctx context.Context, id string) error
	DeleteSessionMessages(ctx context.Context, sessionID string) error
	Flush(ctx context.Context, id string) error
	FlushAll(ctx context.Context) error
}

Service is the public interface to the message store. The actual implementation is provided by the workspace adapter.

type TextContent

type TextContent struct {
	Text string `json:"text"`
}

func (TextContent) String

func (tc TextContent) String() string

type ToolCall

type ToolCall struct {
	ID               string `json:"id"`
	Name             string `json:"name"`
	Input            string `json:"input"`
	ProviderExecuted bool   `json:"provider_executed"`
	Finished         bool   `json:"finished"`
}

type ToolResult

type ToolResult struct {
	ToolCallID string `json:"tool_call_id"`
	Name       string `json:"name"`
	Content    string `json:"content"`
	Data       string `json:"data"`
	MIMEType   string `json:"mime_type"`
	Metadata   string `json:"metadata"`
	IsError    bool   `json:"is_error"`
}

Jump to

Keyboard shortcuts

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