streamblocks

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Text

type Text struct {
	ContentIndex int
	Started      bool
	Closed       bool
	// contains filtered or unexported fields
}

Text accumulates streamed text for one content block.

func (*Text) Append

func (b *Text) Append(delta string) string

Append adds delta and returns the full accumulated text.

func (*Text) Set

func (b *Text) Set(text string)

Set replaces the accumulated text.

func (*Text) String

func (b *Text) String() string

String returns the accumulated text.

type Thinking

type Thinking struct {
	ContentIndex      int
	Signature         string
	ProviderSignature string
	Redacted          bool
	Started           bool
	Closed            bool
	// contains filtered or unexported fields
}

Thinking accumulates streamed thinking for one content block.

func (*Thinking) Append

func (b *Thinking) Append(delta string) string

Append adds delta and returns the full accumulated thinking text.

func (*Thinking) Set

func (b *Thinking) Set(text string)

Set replaces the accumulated thinking text.

func (*Thinking) String

func (b *Thinking) String() string

String returns the accumulated thinking text.

type ToolCall

type ToolCall struct {
	ContentIndex      int
	ProviderSignature string
	Started           bool
	Closed            bool
	// contains filtered or unexported fields
}

ToolCall accumulates streamed tool-call identity and argument fragments.

func (*ToolCall) AppendArguments

func (c *ToolCall) AppendArguments(delta string)

AppendArguments adds an argument fragment.

func (*ToolCall) ArgumentsText

func (c *ToolCall) ArgumentsText() string

ArgumentsText returns the accumulated raw argument text.

func (*ToolCall) ArgumentsValue

func (c *ToolCall) ArgumentsValue() any

ArgumentsValue returns decoded arguments, an empty object for empty arguments, or the raw text while arguments are invalid/incomplete JSON.

func (*ToolCall) DecodeArguments

func (c *ToolCall) DecodeArguments() (any, bool)

DecodeArguments decodes accumulated arguments only when callers need the structured value, caching the result until the argument text changes.

func (*ToolCall) ID

func (c *ToolCall) ID() string

ID returns the accumulated tool-call id.

func (*ToolCall) Name

func (c *ToolCall) Name() string

Name returns the accumulated tool-call name.

func (*ToolCall) Partial

func (c *ToolCall) Partial(argumentsDelta string, mode ToolPartialMode) *sigma.PartialToolCall

Partial builds the public partial tool-call payload for the accumulated state.

func (*ToolCall) SetArguments

func (c *ToolCall) SetArguments(arguments string)

SetArguments replaces the accumulated argument text.

func (*ToolCall) SetID

func (c *ToolCall) SetID(value string)

SetID replaces the tool-call id when value is non-empty.

func (*ToolCall) SetName

func (c *ToolCall) SetName(value string)

SetName replaces the tool-call name when value is non-empty.

func (*ToolCall) ToolCall

func (c *ToolCall) ToolCall() sigma.ToolCall

ToolCall returns the final public tool-call value.

type ToolPartialMode

type ToolPartialMode int

ToolPartialMode controls how partial tool-call metadata is exposed.

const (
	// ToolPartialArgumentsText preserves raw argument text and adds decoded
	// arguments only when the accumulated value is valid JSON.
	ToolPartialArgumentsText ToolPartialMode = iota
	// ToolPartialArguments exposes the provider-neutral arguments value,
	// returning the raw text while JSON is still incomplete.
	ToolPartialArguments
)

Jump to

Keyboard shortcuts

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