Standardize action results
This commit is contained in:
@@ -23,7 +23,7 @@ type ActionCurrentState struct {
|
||||
|
||||
// Actions is something the agent can do
|
||||
type Action interface {
|
||||
Run(ctx context.Context, action action.ActionParams) (string, error)
|
||||
Run(ctx context.Context, action action.ActionParams) (action.ActionResult, error)
|
||||
Definition() action.ActionDefinition
|
||||
}
|
||||
|
||||
|
||||
@@ -242,9 +242,12 @@ func (a *Agent) Memory() RAGDB {
|
||||
func (a *Agent) runAction(chosenAction Action, params action.ActionParams) (result string, err error) {
|
||||
for _, action := range a.systemInternalActions() {
|
||||
if action.Definition().Name == chosenAction.Definition().Name {
|
||||
if result, err = action.Run(a.actionContext, params); err != nil {
|
||||
res, err := action.Run(a.actionContext, params)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error running action: %w", err)
|
||||
}
|
||||
|
||||
result = res.Result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ type TestAction struct {
|
||||
responseN int
|
||||
}
|
||||
|
||||
func (a *TestAction) Run(context.Context, action.ActionParams) (string, error) {
|
||||
func (a *TestAction) Run(context.Context, action.ActionParams) (action.ActionResult, error) {
|
||||
res := a.response[a.responseN]
|
||||
a.responseN++
|
||||
|
||||
@@ -44,7 +44,7 @@ func (a *TestAction) Run(context.Context, action.ActionParams) (string, error) {
|
||||
a.responseN = 0
|
||||
}
|
||||
|
||||
return res, nil
|
||||
return action.ActionResult{Result: res}, nil
|
||||
}
|
||||
|
||||
func (a *TestAction) Definition() action.ActionDefinition {
|
||||
|
||||
Reference in New Issue
Block a user