claude

package
v0.4.21 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const MessageIdMetadataSlug = "claude_message_id"
View Source
const ModelMetadataSlug = "claude_model"
View Source
const RoleMetadataSlug = "claude_role"
View Source
const StopReasonMetadataSlug = "claude_stop_reason"
View Source
const StopSequenceMetadataSlug = "claude_stop_sequence"
View Source
const UsageMetadataSlug = "claude_usage"

Variables

This section is empty.

Functions

func IsClaudeEngine

func IsClaudeEngine(engine string) bool

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 (csf *ChatStep) AddPublishedTopic(publisher message.Publisher, topic string) error

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

type ChatStepOption func(*ChatStep) error

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:

  1. Create a new merger with NewContentBlockMerger()
  2. For each streaming event, call Add() to process and update the internal state
  3. Use Text() to get the current accumulated response text
  4. 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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