fix state update, save/load

This commit is contained in:
mudler
2024-04-04 16:58:25 +02:00
parent 9173156e40
commit b4fd482f66
7 changed files with 151 additions and 23 deletions

View File

@@ -24,7 +24,7 @@ func NewContext(ctx context.Context, cancel context.CancelFunc) *ActionContext {
}
}
type ActionParams map[string]string
type ActionParams map[string]interface{}
func (ap ActionParams) Read(s string) error {
err := json.Unmarshal([]byte(s), &ap)

View File

@@ -1,6 +1,8 @@
package action
import (
"fmt"
"github.com/sashabaranov/go-openai/jsonschema"
)
@@ -31,7 +33,7 @@ type StateResult struct {
}
func (a *StateAction) Run(ActionParams) (string, error) {
return "no-op", nil
return "internal state has been updated", nil
}
func (a *StateAction) Definition() ActionDefinition {
@@ -68,3 +70,23 @@ func (a *StateAction) Definition() ActionDefinition {
},
}
}
const fmtT = `=====================
NowDoing: %s
DoingNext: %s
Your current goal is: %s
You have done: %+v
You have a short memory with: %+v
=====================
`
func (c StateResult) String() string {
return fmt.Sprintf(
fmtT,
c.NowDoing,
c.DoingNext,
c.Goal,
c.DoneHistory,
c.Memories,
)
}