engine

package
v0.0.0-...-a59c08c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithActorStore

func WithActorStore(store *stores.ActorStore) options.Option[Engine]

func WithContext

func WithContext(ctx context.Context) options.Option[Engine]

func WithDB

func WithDB(db *gorm.DB) options.Option[Engine]

func WithIdentifier

func WithIdentifier(id id.ID, name string) options.Option[Engine]

func WithInteractionFragmentStore

func WithInteractionFragmentStore(store *stores.FragmentStore) options.Option[Engine]

func WithLLMClient

func WithLLMClient(client *llm.LLMClient) options.Option[Engine]

func WithLogger

func WithLogger(logger *logger.Logger) options.Option[Engine]

func WithManagerOrder

func WithManagerOrder(order []manager.ManagerID) options.Option[Engine]

func WithManagers

func WithManagers(_managers ...manager.Manager) options.Option[Engine]

func WithSessionStore

func WithSessionStore(store *stores.SessionStore) options.Option[Engine]

Types

type Engine

type Engine struct {
	options.RequiredFields

	ID   id.ID
	Name string
	// contains filtered or unexported fields
}

func New

func New(opts ...options.Option[Engine]) (*Engine, error)

New creates a new Engine instance with the provided options. Returns an error if required fields are missing or if actor creation fails.

func (*Engine) AddManager

func (e *Engine) AddManager(newManager manager.Manager) error

AddManager adds a new manager to the runtime. Validates that: 1. The manager ID is not duplicate 2. All manager dependencies are available Returns an error if validation fails.

func (*Engine) DoesInteractionFragmentExist

func (e *Engine) DoesInteractionFragmentExist(fragmentID id.ID) (bool, error)

func (*Engine) GenerateResponse

func (e *Engine) GenerateResponse(messages []llm.Message, sessionID id.ID, tools ...toolkit.Tool) (*db.Fragment, error)

GenerateResponse creates a new response using the LLM: 1. Generates completion from provided messages 2. Creates embedding for the response 3. Builds response fragment with metadata Returns the response fragment and any error encountered.

func (*Engine) NewState

func (e *Engine) NewState(actorId, sessionId id.ID, input string) (*state.State, error)

func (*Engine) NewStateFromFragment

func (e *Engine) NewStateFromFragment(fragment *db.Fragment) (*state.State, error)

NewState creates a new State instance with the provided options. It initializes an empty state and applies any provided configuration options.

func (*Engine) PostProcess

func (e *Engine) PostProcess(response *db.Fragment, currentState *state.State) error

PostProcess handles the post-processing of a response: 1. Retrieves actor and session information 2. Creates a copy of the response fragment 3. Executes all managers in sequence 4. Stores the processed response Returns an error if any step fails.

func (*Engine) Process

func (e *Engine) Process(currentState *state.State) error

Process handles the processing of a new input through the runtime pipeline: 1. Retrieves actor and session information 2. Creates a copy of the input fragment 3. Executes all managers in parallel 4. Stores the processed input Returns an error if any step fails.

func (*Engine) StartBackgroundProcesses

func (e *Engine) StartBackgroundProcesses()

StartBackgroundProcesses initiates background processes for all managers. Each manager's background process runs in its own goroutine.

func (*Engine) StopBackgroundProcesses

func (e *Engine) StopBackgroundProcesses()

StopBackgroundProcesses terminates background processes for all managers.

func (*Engine) UpdateState

func (e *Engine) UpdateState(s *state.State) error

UpdateState applies the provided options and collects manager data

func (*Engine) UpsertActor

func (e *Engine) UpsertActor(actorID id.ID, actorName string, assistant bool) error

func (*Engine) UpsertInteractionFragment

func (e *Engine) UpsertInteractionFragment(fragment *db.Fragment) error

func (*Engine) UpsertSession

func (e *Engine) UpsertSession(sessionID id.ID) error

func (*Engine) ValidateRequiredFields

func (e *Engine) ValidateRequiredFields() error

Jump to

Keyboard shortcuts

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