chat

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package chat adapts elelem's provider-neutral agent loop to chatz SSE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamStarted

func StreamStarted(err error) bool

StreamStarted reports whether Run emitted any stream event before err. A caller may only retry with another model when this is false: once the stream begins, a client may have displayed output and the agent may have reached a tool-capable round.

Types

type Deps

type Deps struct {
	Client    *elelem.Client
	Tools     ToolExecutor
	Publisher *essessey.Publisher
}

type Request

type Request struct {
	MessageID        string
	ConversationID   string
	Model            elelem.Model
	Prompt           elelem.Prompt
	MaxRounds        int
	MaxContextTokens int
	Params           elelem.GenerationParams
	OnStreamStart    func()
	OnAssistantDelta func(context.Context, elelem.Delta)
	OnFirstDelta     func(context.Context) error
	OnRoundStart     func(context.Context, *elelem.RoundEvent) error
	OnToolCallStart  func(context.Context, elelem.ToolCallEvent) error
}

type Result

type Result struct {
	MessageID string
	ModelID   string
	FinalText string
	Usage     elelem.Usage
	Rounds    int
	Messages  []elelem.Message
}

func Run

func Run(ctx context.Context, deps Deps, req Request) (*Result, error)

type ToolExecutor

type ToolExecutor interface {
	Tools(ctx context.Context) []mcp.Tool
	Call(
		ctx context.Context,
		qualifiedName string,
		args map[string]any,
	) (*mcp.ToolResult, error)
}

Jump to

Keyboard shortcuts

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