cook

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: GPL-3.0 Imports: 31 Imported by: 0

README

AI-gent Cook

This demo presents data collection, gen AI, offers, stories, workflows, dynamic short-term memory, planning with a DAG, story navigation, progress, and clockmoji.

Package Contents

  • aigent-cook
  • config.kdl
  • am-dbg
  • arpc
  • README.md
  • LICENSE.md

Configuration

Providing an AI model is mandatory, edit config.kdl, section AI. The first non-disabled model will be used.

  • for OpenAI, change openaikey to a working one
  • for Gemini, disable // OpenAI, and enable // Gemini, change geminikey to a working one
  • for DeepSeek, disable // OpenAI, enable // DeepSeek, change deepseekkey to a working one
  • for LMstudio, disable // OpenAI, enable // LMStudio, set the correct Model

Start

  1. Start ./aigent-cook
  2. Connect to TUI ssh localhost -p 7855 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

Start With Debugger

  1. In config.kdl, set Debug.DBGAddr to 1 (or a custom addr)
  2. Start ./am-dbg
  3. Start ./aigent-cook

Start With Mock Scenario

  1. In config.kdl, set Debug.Mock to true
  2. Start ./aigent-cook

Start REPL

  1. Start ./aigent-cook
  2. Start ./arpc --dir tmp

Credits

Documentation

Overview

Package cook is a recipe-choosing and cooking agent with a gen-ai character.

Index

Constants

This section is empty.

Variables

View Source
var APrefix = "cook"

APrefix is the args prefix, set from config.

View Source
var PassAA = shared.Pass

PassAA is shared.Pass.

View Source
var SAdd = am.SAdd
View Source
var WelcomeMessage = "Please wait while loading..."

Functions

func LogArgs

func LogArgs(args am.A) map[string]string

LogArgs is an args logger for A and secai.A.

func Pass

func Pass(args *A) am.A

Pass prepares am.A from A to be passed to further mutations (encoder).

func PassRpc

func PassRpc(args *A) am.A

PassRpc is a network-safe version of Pass. Use it when mutating aRPC workers.

Types

type A

type A struct {
	// base args of the framework
	*shared.A

	// agent's args
	Move *sa.ResultOrienting `log:"move"`
	TUI  *tui.Tui
}

A is a struct for node arguments. It's a typesafe alternative to am.A.

func NewArgs added in v0.4.0

func NewArgs() A

func ParseArgs

func ParseArgs(args am.A) *A

ParseArgs extracts A from am.Event.ArgsAPrefix (decoder).

type AA

type AA = shared.A

type AARpc

type AARpc = shared.ARpc

type ARpc

type ARpc struct {
	// base args of the framework
	*shared.A

	// agent's args
	Move *sa.ResultOrienting `log:"move"`
}

ARpc is a subset of A that can be passed over RPC (eg no channels, conns, etc)

func NewArgsRpc added in v0.4.0

func NewArgsRpc() ARpc

type Agent

type Agent struct {
	// inherit from LLM AgentLLM
	*agentllm.AgentLLM

	Config      *Config
	StoriesList []string
	Stories     map[string]*StoryUI
	UIs         []*tui.Tui
	Msgs        []*shared.Msg
	MemCutoff   atomic.Uint64
	UINum       int
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, states am.S, schema am.Schema) *Agent

New returns a custom instance of Agent.

func NewCook

func NewCook(ctx context.Context, cfg *Config) (*Agent, error)

NewCook returns a preconfigured instance of Agent.

func (*Agent) AnyState

func (a *Agent) AnyState(e *am.Event)

func (*Agent) CharacterReadyEnd

func (a *Agent) CharacterReadyEnd(e *am.Event)

func (*Agent) CharacterReadyEnter

func (a *Agent) CharacterReadyEnter(e *am.Event) bool

func (*Agent) CharacterReadyState

func (a *Agent) CharacterReadyState(e *am.Event)

func (*Agent) CheckStoriesState

func (a *Agent) CheckStoriesState(e *am.Event)

func (*Agent) DBStartingState

func (a *Agent) DBStartingState(e *am.Event)

func (*Agent) DisposedState

func (a *Agent) DisposedState(e *am.Event)

func (*Agent) ExceptionState

func (a *Agent) ExceptionState(e *am.Event)

func (*Agent) GenCharacterEnd

func (a *Agent) GenCharacterEnd(e *am.Event)

func (*Agent) GenCharacterState

func (a *Agent) GenCharacterState(e *am.Event)

func (*Agent) GenJokesEnd

func (a *Agent) GenJokesEnd(e *am.Event)

func (*Agent) GenJokesEnter

func (a *Agent) GenJokesEnter(e *am.Event) bool

func (*Agent) GenJokesState

func (a *Agent) GenJokesState(e *am.Event)

func (*Agent) GenResourcesEnd

func (a *Agent) GenResourcesEnd(e *am.Event)

func (*Agent) GenResourcesEnter

func (a *Agent) GenResourcesEnter(e *am.Event) bool

func (*Agent) GenResourcesState

func (a *Agent) GenResourcesState(e *am.Event)

func (*Agent) GenStepCommentsEnd

func (a *Agent) GenStepCommentsEnd(e *am.Event)

func (*Agent) GenStepCommentsState

func (a *Agent) GenStepCommentsState(e *am.Event)

func (*Agent) GenStepsEnd

func (a *Agent) GenStepsEnd(e *am.Event)

func (*Agent) GenStepsState

func (a *Agent) GenStepsState(e *am.Event)

func (*Agent) HeartbeatState

func (a *Agent) HeartbeatState(e *am.Event)

func (*Agent) HistoryStates added in v0.4.0

func (a *Agent) HistoryStates() S

HistoryStates returns a list of states to track in the history.

func (*Agent) IngredientsReadyEnd

func (a *Agent) IngredientsReadyEnd(e *am.Event)

func (*Agent) Init

func (a *Agent) Init(cfg *Config) error

func (*Agent) InputPendingState

func (a *Agent) InputPendingState(e *am.Event)

InputPendingState is a test mocking handler.

func (*Agent) InterruptedState

func (a *Agent) InterruptedState(e *am.Event)

func (*Agent) JokesReadyEnd

func (a *Agent) JokesReadyEnd(e *am.Event)

func (*Agent) LoopEnter

func (a *Agent) LoopEnter(e *am.Event) bool

func (*Agent) LoopState

func (a *Agent) LoopState(e *am.Event)

func (*Agent) MockEnter

func (a *Agent) MockEnter(e *am.Event) bool

func (*Agent) MockState

func (a *Agent) MockState(e *am.Event)

func (*Agent) MsgState

func (a *Agent) MsgState(e *am.Event)

func (*Agent) OrientingMoveEnter

func (a *Agent) OrientingMoveEnter(e *am.Event) bool

func (*Agent) OrientingMoveState

func (a *Agent) OrientingMoveState(e *am.Event)

func (*Agent) OrientingState

func (a *Agent) OrientingState(e *am.Event)

func (*Agent) OutputPhrase

func (a *Agent) OutputPhrase(key string, args ...any) error

OutputPhrase is sugar for Phrase followed by Output FromAssistant.

func (*Agent) Phrase

func (a *Agent) Phrase(key string, args ...any) string

Phrase returns a random phrase from resources under [key], or an empty string. TODO move to base agent

func (*Agent) PromptEnter

func (a *Agent) PromptEnter(e *am.Event) bool

func (*Agent) PromptState

func (a *Agent) PromptState(e *am.Event)

func (*Agent) Queries

func (a *Agent) Queries() *sqlc.Queries

func (*Agent) ReadyEnter

func (a *Agent) ReadyEnter(e *am.Event) bool

func (*Agent) ReadyState

func (a *Agent) ReadyState(e *am.Event)

ReadyState is a test mocking handler.

func (*Agent) ResourcesReadyEnd

func (a *Agent) ResourcesReadyEnd(e *am.Event)

func (*Agent) RestoreCharacterState

func (a *Agent) RestoreCharacterState(e *am.Event)

func (*Agent) RestoreJokesState

func (a *Agent) RestoreJokesState(e *am.Event)

func (*Agent) RestoreResourcesState

func (a *Agent) RestoreResourcesState(e *am.Event)

func (*Agent) StartState

func (a *Agent) StartState(e *am.Event)

func (*Agent) StepCommentsReadyEnd

func (a *Agent) StepCommentsReadyEnd(e *am.Event)

func (*Agent) StepCompletedState

func (a *Agent) StepCompletedState(e *am.Event)

func (*Agent) StepsReadyEnd

func (a *Agent) StepsReadyEnd(e *am.Event)

func (*Agent) StepsReadyState

func (a *Agent) StepsReadyState(e *am.Event)

func (*Agent) StoryActivate

func (a *Agent) StoryActivate(e *am.Event, story string) am.Result

TODO move to base agent

func (*Agent) StoryChangedState

func (a *Agent) StoryChangedState(e *am.Event)

func (*Agent) StoryCookingStartedEnd

func (a *Agent) StoryCookingStartedEnd(e *am.Event)

func (*Agent) StoryCookingStartedEnter

func (a *Agent) StoryCookingStartedEnter(e *am.Event) bool

func (*Agent) StoryCookingStartedState

func (a *Agent) StoryCookingStartedState(e *am.Event)

func (*Agent) StoryDeactivate

func (a *Agent) StoryDeactivate(e *am.Event, story string) am.Result

TODO move to base agent

func (*Agent) StoryIngredientsPickingEnd

func (a *Agent) StoryIngredientsPickingEnd(e *am.Event)

func (*Agent) StoryIngredientsPickingState

func (a *Agent) StoryIngredientsPickingState(e *am.Event)

func (*Agent) StoryJokeEnter

func (a *Agent) StoryJokeEnter(e *am.Event) bool

func (*Agent) StoryJokeState

func (a *Agent) StoryJokeState(e *am.Event)

func (*Agent) StoryMealReadyState

func (a *Agent) StoryMealReadyState(e *am.Event)

func (*Agent) StoryMemoryWipeState

func (a *Agent) StoryMemoryWipeState(e *am.Event)

func (*Agent) StoryRecipePickingEnd

func (a *Agent) StoryRecipePickingEnd(e *am.Event)

func (*Agent) StoryRecipePickingEnter

func (a *Agent) StoryRecipePickingEnter(e *am.Event) bool

func (*Agent) StoryRecipePickingState

func (a *Agent) StoryRecipePickingState(e *am.Event)

func (*Agent) StoryStartAgainState

func (a *Agent) StoryStartAgainState(e *am.Event)

func (*Agent) StoryWakingUpEnd

func (a *Agent) StoryWakingUpEnd(e *am.Event)

func (*Agent) StoryWakingUpState

func (a *Agent) StoryWakingUpState(e *am.Event)

func (*Agent) UIModeEnd

func (a *Agent) UIModeEnd(e *am.Event)

func (*Agent) UIModeState

func (a *Agent) UIModeState(e *am.Event)

func (*Agent) UIReadyEnter

func (a *Agent) UIReadyEnter(e *am.Event) bool

TODO bind

func (*Agent) UISessConnState

func (a *Agent) UISessConnState(e *am.Event)

func (*Agent) UISessDisconnState

func (a *Agent) UISessDisconnState(e *am.Event)

func (*Agent) UISrvListeningState

func (a *Agent) UISrvListeningState(e *am.Event)

type Config

type Config struct {
	shared.Config

	Cook ConfigCook
}

func ConfigDefault added in v0.4.0

func ConfigDefault() Config

type ConfigCook added in v0.4.0

type ConfigCook struct {
	// Number of ingredients to collect.
	MinIngredients int
	GenJokesAmount int
	// TODO move to secai
	SessionTimeout time.Duration `kdl:",duration"`
	// Number of recipes to generate.
	GenRecipes int
	// TODO remove?
	MinPromptLen int
	// Step comment frequency. Lower number = higher frequency of step comments. 2=50%, 3=33%.
	StepCommentFreq int
	// Heartbeat frequency.
	HeartbeatFreq time.Duration `kdl:",duration"`
	// Certainty above which the orienting move should be accepted.
	OrientingMoveThreshold float64
}

type MemHandlers added in v0.4.0

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

func (*MemHandlers) AnyState added in v0.4.0

func (m *MemHandlers) AnyState(_ *am.Event)

type Mock

type Mock struct {
	// Local mock switch, complementary to the config switch.
	Active bool

	FlowPromptIngredients string
	FlowPromptRecipe      string
	FlowPromptCooking     string

	Recipe                    string
	GenStepsRes               string
	GenStepCommentsRes        string
	StoryCookingStartedInput  string
	StoryCookingStartedInput3 string
}

Mock will run a sample scenario

type S

type S = am.S

type StepsByReqFinal

type StepsByReqFinal struct {
	Name   string
	Schema am.Schema
}

type StoryUI

type StoryUI struct {
	*sa.Story

	Actions []shared.StoryAction
}

Directories

Path Synopsis
db
scripts
gen_sql_schema command

Jump to

Keyboard shortcuts

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