Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractText ¶
func ExtractText(raw json.RawMessage) string
ExtractText extracts the text content from a message content field. Content can be either a plain string or an array of content blocks.
func ExtractThinking ¶
func ExtractThinking(raw json.RawMessage) string
ExtractThinking extracts thinking text from content blocks.
func ExtractToolCalls ¶
func ExtractToolCalls(raw json.RawMessage) []string
ExtractToolCalls extracts tool call names from content blocks.
Types ¶
type ChatEventPayload ¶
type ChatEventPayload struct {
SessionKey string `json:"sessionKey"`
RunID string `json:"runId"`
State string `json:"state"`
Message json.RawMessage `json:"message,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
StopReason string `json:"stopReason,omitempty"`
}
ChatEventPayload mirrors the chat event structure for the assembler.
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Thinking string `json:"thinking,omitempty"` // for type "thinking"
Name string `json:"name,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
}
ContentBlock represents a typed content block in a message.
type StreamAssembler ¶
type StreamAssembler struct {
// contains filtered or unexported fields
}
StreamAssembler accumulates streaming chat deltas into a complete response.
func NewStreamAssembler ¶
func NewStreamAssembler() *StreamAssembler
NewStreamAssembler creates a new stream assembler.
func (*StreamAssembler) HandleEvent ¶
func (s *StreamAssembler) HandleEvent(event ChatEventPayload) StreamDelta
HandleEvent processes a chat event and returns the current state.
func (*StreamAssembler) Reset ¶
func (s *StreamAssembler) Reset()
Reset clears the assembler state for a new response.
func (*StreamAssembler) State ¶
func (s *StreamAssembler) State() StreamState
State returns the current stream state.
type StreamDelta ¶
type StreamDelta struct {
RunID string
State StreamState
Text string // Current accumulated text
Thinking string // Current accumulated thinking
Tools []string
Error string
}
StreamDelta represents an incremental update from the assembler.
type StreamState ¶
type StreamState int
StreamState represents the current state of a response stream.
const ( StreamIdle StreamState = iota StreamActive // Receiving deltas StreamFinal // Completed StreamAborted // Cancelled StreamError // Error occurred )