Help us shape the future of Go! Take the 2026 Go Developer Survey

agent

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent[T any] struct {
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent[T any](name, description string, flow *FormFlow[T], store StateReadWriter[T]) *Agent[T]

func (*Agent[T]) Description

func (a *Agent[T]) Description(ctx context.Context) string

func (*Agent[T]) Name

func (a *Agent[T]) Name(ctx context.Context) string

func (*Agent[T]) Run

func (a *Agent[T]) Run(ctx context.Context, input *adk.AgentInput, options ...adk.AgentRunOption) *adk.AsyncIterator[*adk.AgentEvent]

type Cache

type Cache[S any] interface {
	Set(ctx context.Context, key string, val S) error
	Get(ctx context.Context, key string) (S, bool, error)
	Del(ctx context.Context, key string) error
	Exists(ctx context.Context, key string) (bool, error)
}

type FormFlow

type FormFlow[T any] struct {
	PatchHook         func(T, []patch.Operation) ([]patch.Operation, error)
	Spec              FormSpec[T]
	PatchGenerator    patch.Generator[T]
	DialogueGenerator dialogue.Generator[T]
	IndentRecognizer  indent.Recognizer[T]
}

func NewFormFlow

func NewFormFlow[T any](spec FormSpec[T], patchGen patch.Generator[T], dialogGen dialogue.Generator[T], indentRecognizer indent.Recognizer[T]) *FormFlow[T]

func NewToolBasedFormFlow

func NewToolBasedFormFlow[T any](
	spec FormSpec[T],
	chatModel model.ToolCallingChatModel,
) (*FormFlow[T], error)

func (*FormFlow[T]) Invoke

func (a *FormFlow[T]) Invoke(ctx context.Context, input *Request[T]) (*Response[T], error)

func (*FormFlow[T]) Stream added in v0.0.3

func (a *FormFlow[T]) Stream(ctx context.Context, input *Request[T]) (*StreamResponse[T], error)

type FormSpec

type FormSpec[T any] interface {
	Summary(ctx context.Context, current T) string
	MissingFacts(ctx context.Context, current T) []types.FieldInfo
	ValidateFacts(ctx context.Context, current T) []types.FieldInfo
}

type HistoryReadWriter

type HistoryReadWriter interface {
	Load(ctx context.Context) ([]*schema.Message, error)
	Save(ctx context.Context, history []*schema.Message) error
	Clear(ctx context.Context) error
	Append(ctx context.Context, messages ...*schema.Message) ([]*schema.Message, error)
}

type HistoryStore

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

func NewHistoryStore

func NewHistoryStore(store Store[[]*schema.Message]) *HistoryStore

func (*HistoryStore) Append

func (s *HistoryStore) Append(ctx context.Context, messages ...*schema.Message) ([]*schema.Message, error)

func (*HistoryStore) Clear

func (s *HistoryStore) Clear(ctx context.Context) error

func (*HistoryStore) Load

func (s *HistoryStore) Load(ctx context.Context) ([]*schema.Message, error)

func (*HistoryStore) Save

func (s *HistoryStore) Save(ctx context.Context, history []*schema.Message) error

type KeyGen added in v0.0.2

type KeyGen func(ctx context.Context) (string, bool)

type MemoryCache

type MemoryCache[S any] struct {
	// contains filtered or unexported fields
}

func NewMemoryCore

func NewMemoryCore[S any]() *MemoryCache[S]

func (*MemoryCache[S]) Del

func (m *MemoryCache[S]) Del(ctx context.Context, key string) error

func (*MemoryCache[S]) Exists

func (m *MemoryCache[S]) Exists(ctx context.Context, key string) (bool, error)

func (*MemoryCache[S]) Get

func (m *MemoryCache[S]) Get(ctx context.Context, key string) (S, bool, error)

func (*MemoryCache[S]) Set

func (m *MemoryCache[S]) Set(ctx context.Context, key string, val S) error

type Request

type Request[T any] struct {
	State       *State[T]         `json:"state"`
	ChatHistory []*schema.Message `json:"chat_history"`
}

type Response

type Response[T any] struct {
	Message  string            `json:"message,omitempty"`
	State    *State[T]         `json:"state,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type State

type State[T any] struct {
	Phase     types.Phase `` /* 145-byte string literal not displayed */
	FormState T           `json:"form_state" jsonschema:"description=The current state of the form being filled"`
}

type StateReadWriter

type StateReadWriter[T any] interface {
	Load(ctx context.Context) (*State[T], error)
	Save(ctx context.Context, state *State[T]) error
	Clear(ctx context.Context) error
}

type StateStore

type StateStore[T any] struct {
	// contains filtered or unexported fields
}

func NewStateStore

func NewStateStore[T any](
	store Store[*State[T]],
	stateInit func(ctx context.Context) T,
) *StateStore[T]

func (*StateStore[T]) Clear

func (s *StateStore[T]) Clear(ctx context.Context) error

func (*StateStore[T]) Load

func (s *StateStore[T]) Load(ctx context.Context) (*State[T], error)

func (*StateStore[T]) Save

func (s *StateStore[T]) Save(ctx context.Context, state *State[T]) error

type Store

type Store[S any] struct {
	// contains filtered or unexported fields
}

func NewStore added in v0.0.2

func NewStore[S any](core Cache[S], namespace string, keygen KeyGen) Store[S]

func (Store[S]) Del

func (c Store[S]) Del(ctx context.Context) error

func (Store[S]) Exists

func (c Store[S]) Exists(ctx context.Context) (bool, error)

func (Store[S]) Get

func (c Store[S]) Get(ctx context.Context) (S, bool, error)

func (Store[S]) Set

func (c Store[S]) Set(ctx context.Context, val S) error

type StreamResponse added in v0.0.3

type StreamResponse[T any] struct {
	MessageStream *schema.StreamReader[string] `json:"-"`
	State         *State[T]                    `json:"state,omitempty"`
	Metadata      map[string]string            `json:"metadata,omitempty"`
}

Jump to

Keyboard shortcuts

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