fix state update, save/load
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user