Reply when skipping loops
This commit is contained in:
@@ -502,7 +502,8 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
|
|||||||
}
|
}
|
||||||
if count[chosenAction.Definition().Name.String()] > a.options.loopDetectionSteps {
|
if count[chosenAction.Definition().Name.String()] > a.options.loopDetectionSteps {
|
||||||
xlog.Info("Loop detected, stopping agent", "agent", a.Character.Name, "action", chosenAction.Definition().Name)
|
xlog.Info("Loop detected, stopping agent", "agent", a.Character.Name, "action", chosenAction.Definition().Name)
|
||||||
chosenAction = nil
|
a.reply(job, role, conv, actionParams, chosenAction, reasoning)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,13 +571,6 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
|
|||||||
|
|
||||||
job.AddPastAction(chosenAction, &actionParams)
|
job.AddPastAction(chosenAction, &actionParams)
|
||||||
|
|
||||||
var err error
|
|
||||||
conv, err = a.handlePlanning(job.GetContext(), job, chosenAction, actionParams, reasoning, pickTemplate, conv)
|
|
||||||
if err != nil {
|
|
||||||
job.Result.Finish(fmt.Errorf("error running action: %w", err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !job.Callback(types.ActionCurrentState{
|
if !job.Callback(types.ActionCurrentState{
|
||||||
Job: job,
|
Job: job,
|
||||||
Action: chosenAction,
|
Action: chosenAction,
|
||||||
@@ -595,6 +589,13 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
conv, err = a.handlePlanning(job.GetContext(), job, chosenAction, actionParams, reasoning, pickTemplate, conv)
|
||||||
|
if err != nil {
|
||||||
|
job.Result.Finish(fmt.Errorf("error running action: %w", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if selfEvaluation && a.options.initiateConversations &&
|
if selfEvaluation && a.options.initiateConversations &&
|
||||||
chosenAction.Definition().Name.Is(action.ConversationActionName) {
|
chosenAction.Definition().Name.Is(action.ConversationActionName) {
|
||||||
|
|
||||||
@@ -625,8 +626,11 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't have to reply , run the action!
|
// if we have a reply action, we need to run it
|
||||||
if !chosenAction.Definition().Name.Is(action.ReplyActionName) {
|
if chosenAction.Definition().Name.Is(action.ReplyActionName) {
|
||||||
|
a.reply(job, role, conv, actionParams, chosenAction, reasoning)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if !chosenAction.Definition().Name.Is(action.PlanActionName) {
|
if !chosenAction.Definition().Name.Is(action.PlanActionName) {
|
||||||
result, err := a.runAction(job.GetContext(), chosenAction, actionParams)
|
result, err := a.runAction(job.GetContext(), chosenAction, actionParams)
|
||||||
@@ -698,8 +702,11 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.reply(job, role, conv, actionParams, chosenAction, reasoning)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Agent) reply(job *types.Job, role string, conv Messages, actionParams types.ActionParams, chosenAction types.Action, reasoning string) {
|
||||||
job.Result.Conversation = conv
|
job.Result.Conversation = conv
|
||||||
|
|
||||||
// At this point can only be a reply action
|
// At this point can only be a reply action
|
||||||
@@ -760,8 +767,8 @@ func (a *Agent) consumeJob(job *types.Job, role string) {
|
|||||||
// },
|
// },
|
||||||
// )
|
// )
|
||||||
|
|
||||||
if !a.options.forceReasoning {
|
if replyResponse.Message != "" {
|
||||||
xlog.Info("No reasoning, return reply message", "reply", replyResponse.Message, "agent", a.Character.Name)
|
xlog.Info("Return reply message", "reply", replyResponse.Message, "agent", a.Character.Name)
|
||||||
|
|
||||||
msg := openai.ChatCompletionMessage{
|
msg := openai.ChatCompletionMessage{
|
||||||
Role: "assistant",
|
Role: "assistant",
|
||||||
|
|||||||
Reference in New Issue
Block a user