diff --git a/neo/assistant/api.go b/neo/assistant/api.go index 86d5106b..d52849ac 100644 --- a/neo/assistant/api.go +++ b/neo/assistant/api.go @@ -687,9 +687,18 @@ func (ast *Assistant) streamChat( return nil, retry } - var prompt string = "" + // Default prompt + var prompt string = fmt.Sprintf("Try to fix the error following the error message. error:\n %s", exception.Trim(retry)) switch v := promptAny.(type) { - case NextAction: + case bool: // Ignore the error, and return the specific result + if v == false { + return nil, retry + } + + case map[string]interface{}: // Ignore the error, and return the specific result + return v, nil + + case NextAction: // Execute the next action result, err := v.Execute(c, ctx, contents, cb) if err != nil { // chatMessage.New().Error(err.Error()).Done().Callback(cb).Write(c.Writer) @@ -697,7 +706,7 @@ func (ast *Assistant) streamChat( } return result, nil - case string: + case string: // Add the prompt to the messages prompt = v } diff --git a/neo/assistant/hooks.go b/neo/assistant/hooks.go index 76ffad8f..acf39281 100644 --- a/neo/assistant/hooks.go +++ b/neo/assistant/hooks.go @@ -164,16 +164,25 @@ func (ast *Assistant) HookRetry(c *gin.Context, context chatctx.Context, input [ } switch v := v.(type) { - case string: + case string, bool: return v, nil + case map[string]interface{}: - var next NextAction - raw, _ := jsoniter.MarshalToString(v) - err := jsoniter.UnmarshalFromString(raw, &next) - if err != nil { - return nil, err + + // Has Action + if _, has := v["action"]; has { + var next NextAction + raw, _ := jsoniter.MarshalToString(v) + err := jsoniter.UnmarshalFromString(raw, &next) + if err != nil { + return nil, err + } + return &next, nil } - return &next, nil + + // Ignore the error, and return the specific result + return v, nil + } return nil, nil