give reasoning when expanding parameters
This commit is contained in:
@@ -72,7 +72,7 @@ func (a *Agent) decision(
|
||||
}
|
||||
|
||||
if len(resp.Choices) != 1 {
|
||||
return nil, fmt.Errorf("no choices")
|
||||
return nil, fmt.Errorf("no choices: %d", len(resp.Choices))
|
||||
}
|
||||
|
||||
msg := resp.Choices[0].Message
|
||||
@@ -131,7 +131,10 @@ func (a *Agent) generateParameters(ctx context.Context, pickTemplate string, act
|
||||
}
|
||||
|
||||
return a.decision(ctx,
|
||||
conversation,
|
||||
append(conversation, openai.ChatCompletionMessage{
|
||||
Role: "system",
|
||||
Content: fmt.Sprintf("The agent decided to use the tool %s with the following reasoning: %s", act.Definition().Name, reasoning),
|
||||
}),
|
||||
a.systemInternalActions().ToTools(),
|
||||
openai.ToolChoice{
|
||||
Type: openai.ToolTypeFunction,
|
||||
|
||||
@@ -367,7 +367,11 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
||||
return
|
||||
}
|
||||
|
||||
a.logger.Info("===> Generating parameters for", "action", chosenAction.Definition().Name)
|
||||
a.logger.Info("Generating parameters",
|
||||
"agent", a.Character.Name,
|
||||
"action", chosenAction.Definition().Name,
|
||||
"reasoning", reasoning,
|
||||
)
|
||||
|
||||
params, err := a.generateParameters(ctx, pickTemplate, chosenAction, a.currentConversation, reasoning)
|
||||
if err != nil {
|
||||
@@ -375,8 +379,13 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
||||
return
|
||||
}
|
||||
|
||||
a.logger.Info("===> Generated parameters for", "action", chosenAction.Definition().Name)
|
||||
a.logger.Info(params.actionParams.String())
|
||||
a.logger.Info(
|
||||
"Generated parameters",
|
||||
"agent", a.Character.Name,
|
||||
"action", chosenAction.Definition().Name,
|
||||
"reasoning", reasoning,
|
||||
"params", params.actionParams.String(),
|
||||
)
|
||||
|
||||
if params.actionParams == nil {
|
||||
job.Result.Finish(fmt.Errorf("no parameters"))
|
||||
|
||||
Reference in New Issue
Block a user