fix(planning): correctly generate a valid JSON schema (#71)
Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
committed by
GitHub
parent
33483ab4b9
commit
e5e238efc0
@@ -44,16 +44,19 @@ func (a *PlanAction) Definition() ActionDefinition {
|
|||||||
Properties: map[string]jsonschema.Definition{
|
Properties: map[string]jsonschema.Definition{
|
||||||
"subtasks": {
|
"subtasks": {
|
||||||
Type: jsonschema.Array,
|
Type: jsonschema.Array,
|
||||||
Description: "The message to reply with",
|
Description: "The subtasks to be executed",
|
||||||
Properties: map[string]jsonschema.Definition{
|
Items: &jsonschema.Definition{
|
||||||
"action": {
|
Type: jsonschema.Object,
|
||||||
Type: jsonschema.String,
|
Properties: map[string]jsonschema.Definition{
|
||||||
Description: "The action to call",
|
"action": {
|
||||||
Enum: a.plannables,
|
Type: jsonschema.String,
|
||||||
},
|
Description: "The action to call",
|
||||||
"reasoning": {
|
Enum: a.plannables,
|
||||||
Type: jsonschema.String,
|
},
|
||||||
Description: "The reasoning for calling this action",
|
"reasoning": {
|
||||||
|
Type: jsonschema.String,
|
||||||
|
Description: "The reasoning for calling this action",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -215,9 +215,11 @@ func (a *Agent) generateParameters(ctx context.Context, pickTemplate string, act
|
|||||||
func (a *Agent) handlePlanning(ctx context.Context, job *Job, chosenAction Action, actionParams action.ActionParams, reasoning string, pickTemplate string) error {
|
func (a *Agent) handlePlanning(ctx context.Context, job *Job, chosenAction Action, actionParams action.ActionParams, reasoning string, pickTemplate string) error {
|
||||||
// Planning: run all the actions in sequence
|
// Planning: run all the actions in sequence
|
||||||
if !chosenAction.Definition().Name.Is(action.PlanActionName) {
|
if !chosenAction.Definition().Name.Is(action.PlanActionName) {
|
||||||
|
xlog.Debug("no plan action")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xlog.Debug("[planning]...")
|
||||||
planResult := action.PlanResult{}
|
planResult := action.PlanResult{}
|
||||||
if err := actionParams.Unmarshal(&planResult); err != nil {
|
if err := actionParams.Unmarshal(&planResult); err != nil {
|
||||||
return fmt.Errorf("error unmarshalling plan result: %w", err)
|
return fmt.Errorf("error unmarshalling plan result: %w", err)
|
||||||
|
|||||||
@@ -567,6 +567,7 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
|
|
||||||
if actionParams == nil {
|
if actionParams == nil {
|
||||||
job.Result.Finish(fmt.Errorf("no parameters"))
|
job.Result.Finish(fmt.Errorf("no parameters"))
|
||||||
|
xlog.Error("No parameters", "agent", a.Character.Name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user