message

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package message provides message types compatible with Crush's interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Type     string
	Name     string
	Path     string
	MimeType string
	Data     []byte
	// Aliases for compatibility
	FilePath string
	FileName string
	Content  []byte
}

Attachment represents a file attachment.

type BinaryContent

type BinaryContent struct {
	Type     string
	MimeType string
	Data     []byte
	Path     string
}

BinaryContent represents binary data in a message.

type ContentPart

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

ContentPart is a marker interface for content parts.

type ContentText

type ContentText struct {
	Text string
}

ContentText represents text content.

func (ContentText) String

func (c ContentText) String() string

type Duration

type Duration int64

Duration represents a duration in milliseconds.

func (Duration) String

func (d Duration) String() string

String returns a formatted duration string.

type FinishPart

type FinishPart struct {
	Reason  FinishReason
	Message string
	Details string
	Time    int64
}

FinishPart represents the finish metadata.

type FinishReason

type FinishReason string

FinishReason represents the reason a message finished.

const (
	FinishReasonEndTurn   FinishReason = "end_turn"
	FinishReasonCanceled  FinishReason = "canceled"
	FinishReasonMaxTokens FinishReason = "max_tokens"
	FinishReasonError     FinishReason = "error"
)

type Message

type Message struct {
	ID        string
	SessionID string
	Role      Role
	CreatedAt int64
	Provider  string // LLM provider
	Model     string // LLM model
	// contains filtered or unexported fields
}

Message represents a chat message.

func NewMessage

func NewMessage(id, sessionID string, role Role) Message

NewMessage creates a new message.

func (*Message) AddPart

func (m *Message) AddPart(part ContentPart)

AddPart adds a content part to the message.

func (Message) BinaryContent

func (m Message) BinaryContent() []BinaryContent

BinaryContent returns any binary content in the message.

func (Message) Content

func (m Message) Content() ContentText

Content returns the text content.

func (Message) FinishPart

func (m Message) FinishPart() *FinishPart

FinishPart returns the finish part if present.

func (Message) IsFinished

func (m Message) IsFinished() bool

IsFinished returns true if the message is finished.

func (Message) IsSummaryMessage

func (m Message) IsSummaryMessage() bool

IsSummaryMessage returns true if this is a summary message.

func (Message) IsThinking

func (m Message) IsThinking() bool

IsThinking returns true if the message is thinking.

func (Message) Parts

func (m Message) Parts() []ContentPart

Parts returns the content parts.

func (Message) ReasoningContent

func (m Message) ReasoningContent() ReasoningContent

ReasoningContent returns thinking content.

func (Message) ThinkingDuration

func (m Message) ThinkingDuration() Duration

ThinkingDuration returns the thinking duration.

func (Message) ToolCalls

func (m Message) ToolCalls() []ToolCall

ToolCalls returns tool calls from the message.

func (Message) ToolResults

func (m Message) ToolResults() []ToolResult

ToolResults returns tool results from the message.

type ReasoningContent

type ReasoningContent struct {
	Thinking   string
	StartedAt  int64
	EndedAt    int64
	FinishedAt int64 // Alias for EndedAt
}

ReasoningContent represents thinking content.

type Role

type Role string

Role represents the role of a message sender.

const (
	User      Role = "user"
	Assistant Role = "assistant"
	Tool      Role = "tool"
	System    Role = "system"
)

type Service

type Service interface {
	List(ctx context.Context, sessionID string) ([]Message, error)
	Subscribe(ctx context.Context) <-chan pubsub.Event[Message]
}

Service defines the message service interface.

type ToolCall

type ToolCall struct {
	ID        string
	Name      string
	Arguments string
	Input     string // Raw input JSON
	Finished  bool   // Whether the tool call has finished
}

ToolCall represents a tool invocation.

type ToolResult

type ToolResult struct {
	ToolCallID string
	Content    string
	IsError    bool
	Data       []byte // Binary data result
	MIMEType   string // MIME type of data
	Metadata   string // Tool-specific metadata (JSON)
}

ToolResult represents the result of a tool execution.

Jump to

Keyboard shortcuts

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