message

package
v0.1.0-preview.7 Latest Latest
Warning

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

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

Documentation

Overview

Package message owns provider-neutral immutable conversation values.

@import { NamedInterface } from "github.com/spice-framework/spice/annotation/modulith" @NamedInterface("message")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID string

ID identifies one message within a run.

func NewID

func NewID(value string) (ID, error)

NewID validates one externally supplied stable message identifier.

type Message

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

Message is one validated immutable conversation entry.

func New

func New(id ID, role Role, parts ...Part) (Message, error)

New constructs a message and defensively copies its parts.

func (Message) Clone

func (value Message) Clone() Message

Clone returns a deep immutable copy.

func (Message) ID

func (value Message) ID() ID

ID returns the message identity.

func (Message) Parts

func (value Message) Parts() []Part

Parts returns a defensive copy.

func (Message) Role

func (value Message) Role() Role

Role returns the author role.

func (Message) SizeBytes

func (value Message) SizeBytes() int

SizeBytes returns the deterministic in-memory payload accounting used by request and replay bounds.

func (Message) Validate

func (value Message) Validate() error

Validate rejects a zero or corrupted message value.

type Part

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

Part is an immutable bounded content part.

func Extension

func Extension(namespace string, value json.RawMessage) (Part, error)

Extension constructs a namespaced JSON extension part.

func Text

func Text(value string) (Part, error)

Text constructs a text part.

func ToolCall

func ToolCall(callID, name string, arguments json.RawMessage) (Part, error)

ToolCall constructs a model-requested tool call part.

func ToolResult

func ToolResult(callID, name string, result json.RawMessage) (Part, error)

ToolResult constructs a tool result part associated with a call name.

func (Part) CallID

func (part Part) CallID() string

CallID returns the correlation identity for tool-call and tool-result parts.

func (Part) Data

func (part Part) Data() json.RawMessage

Data returns a defensive copy of structured JSON content.

func (Part) Kind

func (part Part) Kind() PartKind

Kind returns the part discriminator.

func (Part) Name

func (part Part) Name() string

Name returns the tool name for tool-call and tool-result parts.

func (Part) Namespace

func (part Part) Namespace() string

Namespace returns the extension namespace.

func (Part) TextValue

func (part Part) TextValue() (string, bool)

TextValue returns text content and whether this is a text part.

type PartKind

type PartKind string

PartKind identifies the one payload carried by a Part.

const (
	PartText       PartKind = "text"
	PartToolCall   PartKind = "tool_call"
	PartToolResult PartKind = "tool_result"
	PartExtension  PartKind = "extension"
)

type Role

type Role string

Role identifies a message author without provider-specific semantics.

const (
	RoleSystem    Role = "system"
	RoleUser      Role = "user"
	RoleAssistant Role = "assistant"
	RoleTool      Role = "tool"
)

Jump to

Keyboard shortcuts

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