Documentation ¶
Index ¶
Constants ¶
const MessageIdMetadataSlug = "claude_message_id"
const ModelMetadataSlug = "claude_model"
const RoleMetadataSlug = "claude_role"
const StopReasonMetadataSlug = "claude_stop_reason"
const StopSequenceMetadataSlug = "claude_stop_sequence"
const UsageMetadataSlug = "claude_usage"
Variables ¶
This section is empty.
Functions ¶
func IsClaudeEngine ¶
Types ¶
type ChatStep ¶ added in v0.4.13
type ChatStep struct { Settings *settings.StepSettings Tools []api.Tool // contains filtered or unexported fields }
func NewChatStep ¶ added in v0.4.13
func NewChatStep( stepSettings *settings.StepSettings, tools []api.Tool, options ...ChatStepOption, ) (*ChatStep, error)
func (*ChatStep) AddPublishedTopic ¶ added in v0.4.13
func (*ChatStep) Start ¶ added in v0.4.13
func (csf *ChatStep) Start( ctx context.Context, messages conversation.Conversation, ) (steps.StepResult[string], error)
type ChatStepOption ¶ added in v0.4.13
func WithChatStepMessageID ¶ added in v0.4.13
func WithChatStepMessageID(messageID conversation.NodeID) ChatStepOption
func WithChatStepParentID ¶ added in v0.4.13
func WithChatStepParentID(parentID conversation.NodeID) ChatStepOption
func WithChatStepSubscriptionManager ¶ added in v0.4.13
func WithChatStepSubscriptionManager(subscriptionManager *events2.PublisherManager) ChatStepOption
type ContentBlockMerger ¶ added in v0.4.13
type ContentBlockMerger struct {
// contains filtered or unexported fields
}
ContentBlockMerger manages the streaming response from Claude AI API for chat completion. It processes various event types to reconstruct the full message response, handling multiple content blocks, metadata updates, and error conditions.
The merger accumulates content from text and tool use blocks, manages message metadata, and provides access to the reconstructed response and any errors encountered.
Usage:
- Create a new merger with NewContentBlockMerger()
- For each streaming event, call Add() to process and update the internal state
- Use Text() to get the current accumulated response text
- Access the full response with Response() or any errors with Error()
The merger handles parallel stream fragments, ensuring proper ordering and combination of content blocks in the final response.
func NewContentBlockMerger ¶ added in v0.4.13
func NewContentBlockMerger(metadata chat.EventMetadata, stepMetadata *steps.StepMetadata) *ContentBlockMerger
func (*ContentBlockMerger) Add ¶ added in v0.4.13
func (cbm *ContentBlockMerger) Add(event api.StreamingEvent) ([]chat.Event, error)
func (*ContentBlockMerger) Error ¶ added in v0.4.13
func (cbm *ContentBlockMerger) Error() *api.Error
func (*ContentBlockMerger) Response ¶ added in v0.4.13
func (cbm *ContentBlockMerger) Response() *api.MessageResponse
func (*ContentBlockMerger) Text ¶ added in v0.4.13
func (cbm *ContentBlockMerger) Text() string
Text returns the accumulated main response so far. In the claude case, this is the concatenated list of all the individual text blocks so far
type MessagesStep ¶ added in v0.4.13
type MessagesStep struct { Settings *settings.StepSettings // contains filtered or unexported fields }
func NewStep ¶ added in v0.2.24
func NewStep(settings *settings.StepSettings) *MessagesStep
func (*MessagesStep) AddPublishedTopic ¶ added in v0.4.13
func (csf *MessagesStep) AddPublishedTopic(publisher message.Publisher, topic string) error
func (*MessagesStep) Interrupt ¶ added in v0.4.13
func (csf *MessagesStep) Interrupt()
func (*MessagesStep) Start ¶ added in v0.4.13
func (csf *MessagesStep) Start( ctx context.Context, messages conversation.Conversation, ) (steps.StepResult[string], error)