chat

package
v0.4.19 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: 7

Documentation

Index

Constants

View Source
const MetadataToolCallsSlug = "tool-calls"

MetadataToolCallsSlug is the slug used to store ToolCall metadata as returned by the openai API TODO(manuel, 2024-07-04) This needs to deleted once we have a good way to do tool calling

Variables

This section is empty.

Functions

func StepPrinterFunc added in v0.4.1

func StepPrinterFunc(name string, w io.Writer) func(msg *message.Message) error

func ToTypedEvent added in v0.4.1

func ToTypedEvent[T any](e Event) (*T, bool)

Types

type AddToHistoryStep added in v0.2.24

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

func (*AddToHistoryStep) AddPublishedTopic added in v0.4.1

func (a *AddToHistoryStep) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*AddToHistoryStep) Start added in v0.2.24

type EchoStep added in v0.2.24

type EchoStep struct {
	TimePerCharacter time.Duration
	// contains filtered or unexported fields
}

func NewEchoStep added in v0.2.24

func NewEchoStep() *EchoStep

func (*EchoStep) AddPublishedTopic added in v0.4.1

func (e *EchoStep) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*EchoStep) Interrupt added in v0.2.24

func (e *EchoStep) Interrupt()

func (*EchoStep) Start added in v0.2.24

type Event added in v0.2.24

type Event interface {
	Type() EventType
	Metadata() EventMetadata
	StepMetadata() *steps.StepMetadata
	Payload() []byte
}

func NewEventFromJson added in v0.4.1

func NewEventFromJson(b []byte) (Event, error)

type EventError added in v0.4.13

type EventError struct {
	EventImpl
	Error_ string `json:"error"`
}

func NewErrorEvent added in v0.4.13

func NewErrorEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata, err string) *EventError

func (EventError) MarshalZerologObject added in v0.4.13

func (e EventError) MarshalZerologObject(ev *zerolog.Event)

type EventFinal added in v0.4.13

type EventFinal struct {
	EventImpl
	Text string `json:"text"`
}

func NewFinalEvent added in v0.4.13

func NewFinalEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata, text string) *EventFinal

func (EventFinal) MarshalZerologObject added in v0.4.13

func (e EventFinal) MarshalZerologObject(ev *zerolog.Event)

type EventImpl added in v0.4.13

type EventImpl struct {
	Type_     EventType           `json:"type"`
	Error_    error               `json:"error,omitempty"`
	Metadata_ EventMetadata       `json:"meta,omitempty"`
	Step_     *steps.StepMetadata `json:"step,omitempty"`
	// contains filtered or unexported fields
}

func (*EventImpl) Error added in v0.4.13

func (e *EventImpl) Error() error

func (*EventImpl) MarshalZerologObject added in v0.4.13

func (e *EventImpl) MarshalZerologObject(ev *zerolog.Event)

func (*EventImpl) Metadata added in v0.4.13

func (e *EventImpl) Metadata() EventMetadata

func (*EventImpl) Payload added in v0.4.13

func (e *EventImpl) Payload() []byte

func (*EventImpl) StepMetadata added in v0.4.13

func (e *EventImpl) StepMetadata() *steps.StepMetadata

func (*EventImpl) ToPartialCompletion added in v0.4.13

func (e *EventImpl) ToPartialCompletion() (EventPartialCompletion, bool)

func (*EventImpl) ToText added in v0.4.13

func (e *EventImpl) ToText() (EventText, bool)

func (*EventImpl) ToToolCall added in v0.4.13

func (e *EventImpl) ToToolCall() (EventToolCall, bool)

func (*EventImpl) Type added in v0.4.13

func (e *EventImpl) Type() EventType

type EventInterrupt added in v0.4.13

type EventInterrupt struct {
	EventImpl
	Text string `json:"text"`
}

func NewInterruptEvent added in v0.4.13

func NewInterruptEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata, text string) *EventInterrupt

func (EventInterrupt) MarshalZerologObject added in v0.4.13

func (e EventInterrupt) MarshalZerologObject(ev *zerolog.Event)

type EventMetadata added in v0.4.1

type EventMetadata struct {
	ID       conversation.NodeID `json:"message_id"`
	ParentID conversation.NodeID `json:"parent_id"`
}

EventMetadata contains all the information that is passed along with watermill message, specific to chat steps.

func (EventMetadata) MarshalZerologObject added in v0.4.13

func (em EventMetadata) MarshalZerologObject(e *zerolog.Event)

type EventPartialCompletion added in v0.4.1

type EventPartialCompletion struct {
	EventImpl
	Delta string `json:"delta"`
	// This is the complete completion string so far (when using openai, this is currently also the toolcall json)
	Completion string `json:"completion"`
}

EventPartialCompletion is the event type for textual partial completion. We don't support partial tool completion.

func NewPartialCompletionEvent added in v0.4.13

func NewPartialCompletionEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata, delta string, completion string) *EventPartialCompletion

func (EventPartialCompletion) MarshalZerologObject added in v0.4.13

func (e EventPartialCompletion) MarshalZerologObject(ev *zerolog.Event)

type EventPartialCompletionStart added in v0.4.13

type EventPartialCompletionStart struct {
	EventImpl
}

func NewStartEvent added in v0.4.13

func NewStartEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata) *EventPartialCompletionStart

func (EventPartialCompletionStart) MarshalZerologObject added in v0.4.13

func (e EventPartialCompletionStart) MarshalZerologObject(ev *zerolog.Event)

type EventText added in v0.4.1

type EventText struct {
	EventImpl
	Text string `json:"text"`
}

TODO(manuel, 2024-07-05) This might be possible to delete

func NewTextEvent added in v0.4.13

func NewTextEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata, text string) *EventText

func (EventText) MarshalZerologObject added in v0.4.13

func (e EventText) MarshalZerologObject(ev *zerolog.Event)

type EventToolCall added in v0.4.13

type EventToolCall struct {
	EventImpl
	ToolCall ToolCall `json:"tool_call"`
}

TODO(manuel, 2024-07-04) Handle multiple tool calls

func NewToolCallEvent added in v0.4.13

func NewToolCallEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata, toolCall ToolCall) *EventToolCall

func (EventToolCall) MarshalZerologObject added in v0.4.13

func (e EventToolCall) MarshalZerologObject(ev *zerolog.Event)

type EventToolResult added in v0.4.13

type EventToolResult struct {
	EventImpl
	ToolResult ToolResult `json:"tool_result"`
}

func NewToolResultEvent added in v0.4.13

func NewToolResultEvent(metadata EventMetadata, stepMetadata *steps.StepMetadata, toolResult ToolResult) *EventToolResult

func (EventToolResult) MarshalZerologObject added in v0.4.13

func (e EventToolResult) MarshalZerologObject(ev *zerolog.Event)

type EventType added in v0.2.24

type EventType string
const (
	// EventTypeStart to EventTypeFinal are for text completion, actually
	EventTypeStart             EventType = "start"
	EventTypeFinal             EventType = "final"
	EventTypePartialCompletion EventType = "partial"

	// TODO(manuel, 2024-07-04) I'm not sure if this is needed
	EventTypeStatus EventType = "status"

	// TODO(manuel, 2024-07-04) Should potentially have a EventTypeText for a block stop here
	EventTypeToolCall   EventType = "tool-call"
	EventTypeToolResult EventType = "tool-result"
	EventTypeError      EventType = "error"
	EventTypeInterrupt  EventType = "interrupt"
)

type RunnableStep added in v0.2.24

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

func (*RunnableStep) AddPublishedTopic added in v0.4.1

func (r *RunnableStep) AddPublishedTopic(publisher message.Publisher, topic string) error

func (*RunnableStep) Start added in v0.2.24

func (r *RunnableStep) Start(ctx context.Context, input interface{}) (steps.StepResult[string], error)

type StepOption added in v0.2.24

type StepOption func(Step) error

func WithPublishedTopic added in v0.4.5

func WithPublishedTopic(publisher message.Publisher, topic string) StepOption

type ToolCall added in v0.4.1

type ToolCall struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Input string `json:"input"`
}

func (ToolCall) MarshalZerologObject added in v0.4.13

func (tc ToolCall) MarshalZerologObject(ev *zerolog.Event)

type ToolResult added in v0.4.13

type ToolResult struct {
	ID     string `json:"id"`
	Result string `json:"result"`
}

func (ToolResult) MarshalZerologObject added in v0.4.13

func (tr ToolResult) MarshalZerologObject(ev *zerolog.Event)

Jump to

Keyboard shortcuts

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