sampling

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotations

type Annotations struct {
	Audience     []Role   `json:"audience,omitempty"`
	Priority     *float64 `json:"priority,omitempty"`
	LastModified string   `json:"lastModified,omitempty"`
}

Annotations correspond to the MCP spec annotations object and are advisory hints.

type Audio

type Audio struct {
	Data        []byte       `json:"-"`
	MIMEType    string       `json:"mimeType"`
	Annotations *Annotations `json:"annotations,omitempty"`
}

Audio content block.

func (Audio) AsContentBlock

func (a Audio) AsContentBlock() mcp.ContentBlock

type Content

type Content interface {
	AsContentBlock() mcp.ContentBlock
	// contains filtered or unexported methods
}

Content represents exactly one content block in a sampling message.

type CreateSpec

type CreateSpec struct {
	History        []Message
	ModelPrefs     *mcp.ModelPreferences
	Temperature    *float64
	MaxTokens      *int
	StopSequences  []string
	Metadata       map[string]any
	IncludeContext string
}

CreateSpec is the compiled form of a CreateMessage invocation prior to translation into the wire request. It replaces the previous exported Options+Accumulate pattern while keeping the functional option surface. This lets the engine depend only on a stable value object without exposing intermediate accumulation APIs.

func (CreateSpec) Compile

func (CreateSpec) Compile(opts ...Option) CreateSpec

Compile applies options to the receiver and returns a populated copy. Typical usage: spec := sampling.CreateSpec{}.Compile(opts...) The receiver is ignored other than its zero-ness; a new value is built.

type Image

type Image struct {
	Data        []byte       `json:"-"`
	MIMEType    string       `json:"mimeType"`
	Alt         string       `json:"alt,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
}

Image content block (raw bytes encoded later at the transport adapter boundary).

func (Image) AsContentBlock

func (i Image) AsContentBlock() mcp.ContentBlock

type Message

type Message struct {
	Role    Role    `json:"role"`
	Content Content `json:"content"`
}

Message represents a single role + single content block.

func AssistantText

func AssistantText(s string) Message

func NewMessage

func NewMessage(role Role, c Content) Message

NewMessage constructs a Message with the given role and content.

func SystemText

func SystemText(s string) Message

func UserText

func UserText(s string) Message

Convenience helpers.

type Option

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

Option is the public handle for configuring a sampling CreateMessage request. It deliberately does not reference internal types to avoid import cycles.

func WithHistory

func WithHistory(msgs ...Message) Option

WithHistory supplies prior conversation turns (excluding the current user message argument).

func WithIncludeContext

func WithIncludeContext(kind string) Option

WithIncludeContext requests the client include additional context (semantics defined by client impl).

func WithMaxTokens

func WithMaxTokens(n int) Option

WithMaxTokens caps the number of tokens for the generated message.

func WithMetadata

func WithMetadata(meta map[string]any) Option

WithMetadata attaches arbitrary metadata (shallow copied).

func WithModelPreferences

func WithModelPreferences(prefs *mcp.ModelPreferences) Option

WithModelPreferences supplies model names / capabilities preferences.

func WithStopSequences

func WithStopSequences(stops ...string) Option

WithStopSequences replaces stop sequences.

func WithTemperature

func WithTemperature(t float64) Option

WithTemperature sets the sampling temperature.

type Role

type Role string

Role identifies the speaker of a sampling message.

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

type Text

type Text struct {
	Text        string       `json:"text"`
	Annotations *Annotations `json:"annotations,omitempty"`
}

Text content block.

func (Text) AsContentBlock

func (t Text) AsContentBlock() mcp.ContentBlock

Jump to

Keyboard shortcuts

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