stream

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package stream provides interfaces for streaming conversations.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoContent = errors.New("no content")

ErrNoContent happens when the client is returning no content.

Functions

func CallTool

func CallTool(
	id, name string,
	data []byte,
	caller func(name string, data []byte) (string, error),
) (proto.Message, proto.ToolCallStatus)

CallTool calls a tool using the provided data and caller, and returns the resulting proto.Message and proto.ToolCallStatus.

Types

type Client

type Client interface {
	Request(context.Context, proto.Request) Stream
}

Client is a streaming client.

type Stream

type Stream interface {
	// returns false when no more messages, caller should run [Stream.CallTools()]
	// once that happens, and then check for this again
	Next() bool

	// the current chunk
	// implementation should accumulate chunks into a message, and keep its
	// internal conversation state
	Current() (proto.Chunk, error)

	// closes the underlying stream
	Close() error

	// streaming error
	Err() error

	// the whole conversation
	Messages() []proto.Message

	// handles any pending tool calls
	CallTools() []proto.ToolCallStatus
}

Stream is an ongoing stream.

Jump to

Keyboard shortcuts

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