assembler

package
v0.260430.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: MPL-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicBetaSDKAssembler

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

AnthropicBetaSDKAssembler wraps the SDK's BetaMessage.Accumulate method for v1 beta API streams.

func NewAnthropicBetaSDKAssembler

func NewAnthropicBetaSDKAssembler() *AnthropicBetaSDKAssembler

NewAnthropicBetaSDKAssembler creates a new assembler for v1 beta streams.

func (*AnthropicBetaSDKAssembler) Accumulate

Accumulate processes a v1 beta stream event using the SDK's accumulation logic.

func (*AnthropicBetaSDKAssembler) Finish

Finish returns the accumulated BetaMessage.

func (*AnthropicBetaSDKAssembler) Result

Result returns the internal message for direct access if needed.

type AnthropicSDKAssembler

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

AnthropicSDKAssembler wraps the SDK's Message.Accumulate method providing a unified interface for stream accumulation.

func NewAnthropicSDKAssembler

func NewAnthropicSDKAssembler() *AnthropicSDKAssembler

NewAnthropicSDKAssembler creates a new assembler using the SDK's accumulate pattern.

func (*AnthropicSDKAssembler) Accumulate

Accumulate processes a stream event using the SDK's built-in accumulation logic. Returns an error if accumulation fails.

func (*AnthropicSDKAssembler) Finish

Finish returns the accumulated Message.

func (*AnthropicSDKAssembler) Result

Result returns the internal message for direct access if needed.

type AnthropicStreamAssembler

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

AnthropicStreamAssembler assembles Anthropic streaming responses It is a pure assembler that doesn't depend on recording logic

func NewAnthropicStreamAssembler

func NewAnthropicStreamAssembler() *AnthropicStreamAssembler

NewAnthropicStreamAssembler creates a new assembler for Anthropic streams

func (*AnthropicStreamAssembler) Finish

func (a *AnthropicStreamAssembler) Finish(model string, inputTokens, outputTokens int) *anthropic.Message

Finish assembles the final response and returns it as anthropic.Message

func (*AnthropicStreamAssembler) RecordV1BetaEvent

RecordV1BetaEvent processes a v1 beta stream event

func (*AnthropicStreamAssembler) RecordV1Event

RecordV1Event processes a v1 stream event

func (*AnthropicStreamAssembler) SetUsage

func (a *AnthropicStreamAssembler) SetUsage(inputTokens, outputTokens int)

SetUsage sets the usage data

type OpenAIChatStreamAssembler

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

OpenAIChatStreamAssembler wraps the SDK's ChatCompletionAccumulator providing a unified interface for stream accumulation.

func NewOpenAIStreamAssembler

func NewOpenAIStreamAssembler() *OpenAIChatStreamAssembler

NewOpenAIStreamAssembler creates a new assembler for OpenAI streams

func (*OpenAIChatStreamAssembler) AddChunk

AddChunk incorporates a chunk into the accumulation. Chunks must be added in order. Returns false if accumulation failed.

func (*OpenAIChatStreamAssembler) Finish

Finish returns the accumulated ChatCompletion.

func (*OpenAIChatStreamAssembler) JustFinishedContent

func (a *OpenAIChatStreamAssembler) JustFinishedContent() (string, bool)

JustFinishedContent returns the content when it was just completed. If the content is just completed, returns (content, true), otherwise ("", false).

func (*OpenAIChatStreamAssembler) JustFinishedRefusal

func (a *OpenAIChatStreamAssembler) JustFinishedRefusal() (string, bool)

JustFinishedRefusal returns the refusal when it was just completed.

func (*OpenAIChatStreamAssembler) JustFinishedToolCall

JustFinishedToolCall returns a tool call when it was just completed. Note: Not reliable with ParallelToolCalls enabled.

func (*OpenAIChatStreamAssembler) Result

Result returns the internal accumulator for direct access if needed.

type ResponsesAssembler

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

ResponsesAssembler accumulates OpenAI Responses API streaming events. It focuses on core functionality: text accumulation, tool calls, and final response construction. Inspired by internal/protocol/stream/anthropic_to_openai_responses.go

func NewResponsesAssembler

func NewResponsesAssembler() *ResponsesAssembler

NewResponsesAssembler creates a new Responses API stream assembler.

func NewResponsesAssemblerWithID

func NewResponsesAssemblerWithID(responseID, itemID string) *ResponsesAssembler

NewResponsesAssemblerWithID creates a new assembler with specific IDs (useful for testing)

func (*ResponsesAssembler) Accumulate

Accumulate processes a Responses API stream event. Returns true if the event was handled, false otherwise.

func (*ResponsesAssembler) CurrentRefusal

func (a *ResponsesAssembler) CurrentRefusal() string

CurrentRefusal returns the refusal text if the model refused to respond.

func (*ResponsesAssembler) CurrentText

func (a *ResponsesAssembler) CurrentText() string

CurrentText returns the text being accumulated for the current part.

func (*ResponsesAssembler) Finish

func (a *ResponsesAssembler) Finish() *responses.Response

Finish returns the accumulated result. If the stream completed successfully, returns the Response. Otherwise, returns nil - check Status() to determine the outcome.

func (*ResponsesAssembler) GetOrCreateItemID

func (a *ResponsesAssembler) GetOrCreateItemID() string

GetOrCreateItemID returns the item ID, generating one if not set.

func (*ResponsesAssembler) GetOrCreateResponseID

func (a *ResponsesAssembler) GetOrCreateResponseID() string

GetOrCreateResponseID returns the response ID, generating one if not set.

func (*ResponsesAssembler) IsCompleted

func (a *ResponsesAssembler) IsCompleted() bool

IsCompleted returns true if the response is completed.

func (*ResponsesAssembler) IsFailed

func (a *ResponsesAssembler) IsFailed() bool

IsFailed returns true if the response failed.

func (*ResponsesAssembler) IsFinished

func (a *ResponsesAssembler) IsFinished() bool

IsFinished returns true if the stream has finished (completed, failed, incomplete, or error).

func (*ResponsesAssembler) IsIncomplete

func (a *ResponsesAssembler) IsIncomplete() bool

IsIncomplete returns true if the response was incomplete.

func (*ResponsesAssembler) OutputText

func (a *ResponsesAssembler) OutputText() string

OutputText returns the accumulated output text.

func (*ResponsesAssembler) Response

func (a *ResponsesAssembler) Response() *responses.Response

Response returns the final Response object when completed. Returns nil if the response is not yet completed or failed.

func (*ResponsesAssembler) ResponseID

func (a *ResponsesAssembler) ResponseID() string

ResponseID returns the response ID.

func (*ResponsesAssembler) SetItemID

func (a *ResponsesAssembler) SetItemID(id string)

SetItemID sets a custom item ID.

func (*ResponsesAssembler) SetResponseID

func (a *ResponsesAssembler) SetResponseID(id string)

SetResponseID sets a custom response ID.

func (*ResponsesAssembler) Status

func (a *ResponsesAssembler) Status() string

Status returns the current response status.

func (*ResponsesAssembler) ToolCalls

func (a *ResponsesAssembler) ToolCalls() map[int]ToolCallInfo

ToolCalls returns the accumulated tool calls. Returns a map of output index to tool call details.

type ToolCallInfo

type ToolCallInfo struct {
	ItemID    string
	Name      string
	Arguments string
}

ToolCallInfo contains information about a tool call.

Jump to

Keyboard shortcuts

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