Documentation
¶
Index ¶
- type AssistantPhase
- type Builder
- func (b *Builder) Build() Message
- func (b *Builder) Cache(opts ...CacheOpt) *Builder
- func (b *Builder) IntoMessage() Message
- func (b *Builder) IntoMessages() []Message
- func (b *Builder) Part(part IntoPart) *Builder
- func (b *Builder) Parts(parts ...IntoPart) *Builder
- func (b *Builder) Phase(phase AssistantPhase) *Builder
- func (b *Builder) Text(text string) *Builder
- func (b *Builder) Thought(thought, signature string) *Builder
- func (b *Builder) ToolCalls(toolCalls ...ToolCall) *Builder
- type CacheHint
- type CacheOpt
- type CacheTTL
- type IntoMessage
- type IntoMessages
- type IntoPart
- type IntoParts
- type IntoToolResults
- type Message
- func (m Message) IntoMessage() Message
- func (m Message) IntoMessages() []Message
- func (m Message) IsAssistant() bool
- func (m Message) IsDeveloper() bool
- func (m Message) IsEmpty() bool
- func (m Message) IsEmptyText() bool
- func (m Message) IsSystem() bool
- func (m Message) IsTool() bool
- func (m Message) IsUser() bool
- func (m Message) Text() string
- func (m Message) ToolCalls() ToolCalls
- func (m Message) ToolResults() ToolResults
- func (m Message) Validate() error
- type Messages
- func (t Messages) Append(m IntoMessages) Messages
- func (t Messages) Filter(pred func(Message) bool) Messages
- func (t Messages) FilterByRole(role Role) Messages
- func (t Messages) IntoMessages() []Message
- func (t Messages) PartsByType(partType PartType) Parts
- func (t Messages) System() Messages
- func (t Messages) Validate() error
- type Part
- type PartType
- type Parts
- type PartsBuilder
- func (b *PartsBuilder) Build() Parts
- func (b *PartsBuilder) IntoParts() Parts
- func (b *PartsBuilder) Part(part Part) *PartsBuilder
- func (b *PartsBuilder) Parts(parts Parts) *PartsBuilder
- func (b *PartsBuilder) PartsFrom(parts IntoParts) *PartsBuilder
- func (b *PartsBuilder) Text(text string) *PartsBuilder
- func (b *PartsBuilder) Thinking(thought, signature string) *PartsBuilder
- func (b *PartsBuilder) ToolCall(toolCall ToolCall) *PartsBuilder
- func (b *PartsBuilder) ToolResult(toolResult ToolResult) Part
- type Role
- type ThinkingPart
- type ToolArgs
- type ToolCall
- type ToolCalls
- type ToolMsgBuilder
- type ToolResult
- type ToolResults
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssistantPhase ¶ added in v0.40.0
type AssistantPhase string
AssistantPhase preserves OpenAI/OpenRouter Responses assistant output phase across request/history roundtrips.
const ( AssistantPhaseCommentary AssistantPhase = "commentary" AssistantPhaseFinalAnswer AssistantPhase = "final_answer" )
func (AssistantPhase) IsEmpty ¶ added in v0.40.0
func (p AssistantPhase) IsEmpty() bool
func (AssistantPhase) Valid ¶ added in v0.40.0
func (p AssistantPhase) Valid() bool
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func BuildFrom ¶
func BuildFrom(intoMsg IntoMessage) *Builder
func (*Builder) IntoMessage ¶
func (*Builder) IntoMessages ¶
func (*Builder) Phase ¶ added in v0.40.0
func (b *Builder) Phase(phase AssistantPhase) *Builder
type CacheHint ¶
type CacheHint struct {
// Enabled marks this content as a cache breakpoint candidate.
// For Anthropic/Bedrock: emits cache_control / cachePoint at this position.
// For OpenAI: no-op (caching is automatic).
Enabled bool `json:"enabled,omitempty"`
// TTL requests a specific cache duration.
// Valid values: "" (provider default, typically 5m), "5m", "1h".
// The "1h" option requires a supporting model (Claude Haiku/Sonnet/Opus 4.5+).
TTL string `json:"ttl,omitempty"`
}
CacheHint requests provider-side prompt caching for a message or request. It is a provider-neutral instruction: Anthropic and Bedrock translate it to explicit cache breakpoints on content blocks; OpenAI caching is always automatic and ignores per-message hints, but honours TTL on Request.CacheHint.
func NewCacheHint ¶
type CacheTTL ¶
type CacheTTL string
const ( CacheTTLUnspecified CacheTTL = "" CacheTTL5m CacheTTL = "5m" CacheTTL1h CacheTTL = "1h" CacheTTLDefault = CacheTTL5m )
type IntoMessage ¶
type IntoMessage interface{ IntoMessage() Message }
type IntoMessages ¶
type IntoMessages interface{ IntoMessages() []Message }
type IntoToolResults ¶
type IntoToolResults interface {
IntoToolResults() ToolResults
}
type Message ¶
type Message struct {
Role Role `json:"role"`
Parts Parts `json:"parts"`
Phase AssistantPhase `json:"phase,omitempty"`
CacheHint *CacheHint `json:"cache_hint,omitempty"`
}
func (Message) IntoMessage ¶
func (Message) IntoMessages ¶
func (Message) IsAssistant ¶
func (Message) IsDeveloper ¶
func (Message) IsEmptyText ¶
func (Message) ToolResults ¶
func (m Message) ToolResults() ToolResults
type Messages ¶
type Messages []Message
func BuildTranscript ¶
func BuildTranscript(msg ...IntoMessages) Messages
func (Messages) Append ¶
func (t Messages) Append(m IntoMessages) Messages
func (Messages) FilterByRole ¶
func (Messages) IntoMessages ¶
func (Messages) PartsByType ¶
type Part ¶
type Part struct {
Type PartType `json:"type"`
Text string `json:"text,omitempty"`
ToolCall *ToolCall `json:"tool_call,omitempty"`
ToolResult *ToolResult `json:"tool_result,omitempty"`
Thinking *ThinkingPart `json:"thinking,omitempty"`
}
type PartsBuilder ¶
type PartsBuilder struct {
// contains filtered or unexported fields
}
func BuildParts ¶
func BuildParts() *PartsBuilder
func (*PartsBuilder) Build ¶
func (b *PartsBuilder) Build() Parts
func (*PartsBuilder) IntoParts ¶
func (b *PartsBuilder) IntoParts() Parts
func (*PartsBuilder) Part ¶
func (b *PartsBuilder) Part(part Part) *PartsBuilder
func (*PartsBuilder) Parts ¶
func (b *PartsBuilder) Parts(parts Parts) *PartsBuilder
func (*PartsBuilder) PartsFrom ¶
func (b *PartsBuilder) PartsFrom(parts IntoParts) *PartsBuilder
func (*PartsBuilder) Text ¶
func (b *PartsBuilder) Text(text string) *PartsBuilder
func (*PartsBuilder) Thinking ¶
func (b *PartsBuilder) Thinking(thought, signature string) *PartsBuilder
func (*PartsBuilder) ToolCall ¶
func (b *PartsBuilder) ToolCall(toolCall ToolCall) *PartsBuilder
func (*PartsBuilder) ToolResult ¶
func (b *PartsBuilder) ToolResult(toolResult ToolResult) Part
type ThinkingPart ¶
type ThinkingPart struct {
Provider string `json:"provider,omitempty"`
Text string `json:"text,omitempty"`
Signature string `json:"signature,omitempty"`
}
func (ThinkingPart) IntoMessage ¶
func (p ThinkingPart) IntoMessage() Message
func (ThinkingPart) IntoPart ¶
func (p ThinkingPart) IntoPart() Part
func (ThinkingPart) Validate ¶
func (p ThinkingPart) Validate() error
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Args ToolArgs `json:"args"`
}
func NewToolCall ¶
NewToolCall creates a ToolCall with a non-nil Args map.
type ToolMsgBuilder ¶
type ToolMsgBuilder struct {
// contains filtered or unexported fields
}
func Tool ¶
func Tool() *ToolMsgBuilder
func (*ToolMsgBuilder) Empty ¶
func (b *ToolMsgBuilder) Empty() *Builder
func (*ToolMsgBuilder) Results ¶
func (b *ToolMsgBuilder) Results(src IntoToolResults) *Builder
type ToolResult ¶
type ToolResult struct {
ToolCallID string `json:"tool_call_id"`
ToolOutput string `json:"output"`
IsError bool `json:"is_error,omitempty"`
}
func (ToolResult) IntoMessage ¶
func (t ToolResult) IntoMessage() Message
func (ToolResult) IntoMessages ¶
func (t ToolResult) IntoMessages() []Message
func (ToolResult) IntoPart ¶
func (t ToolResult) IntoPart() Part
func (ToolResult) IntoParts ¶
func (t ToolResult) IntoParts() []Part
func (ToolResult) IntoToolResults ¶
func (t ToolResult) IntoToolResults() ToolResults
func (ToolResult) Validate ¶
func (t ToolResult) Validate() error
type ToolResults ¶
type ToolResults []ToolResult
func (ToolResults) IntoParts ¶
func (t ToolResults) IntoParts() []Part
func (ToolResults) IntoToolResults ¶
func (t ToolResults) IntoToolResults() ToolResults
Click to show internal directories.
Click to hide internal directories.