Enhance logging
This commit is contained in:
@@ -565,6 +565,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
if followingAction != nil &&
|
if followingAction != nil &&
|
||||||
!followingAction.Definition().Name.Is(action.ReplyActionName) &&
|
!followingAction.Definition().Name.Is(action.ReplyActionName) &&
|
||||||
!chosenAction.Definition().Name.Is(action.ReplyActionName) {
|
!chosenAction.Definition().Name.Is(action.ReplyActionName) {
|
||||||
|
xlog.Info("Following action", "action", followingAction.Definition().Name, "agent", a.Character.Name)
|
||||||
|
|
||||||
// We need to do another action (?)
|
// We need to do another action (?)
|
||||||
// The agent decided to do another action
|
// The agent decided to do another action
|
||||||
// call ourselves again
|
// call ourselves again
|
||||||
@@ -575,7 +577,11 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
a.consumeJob(job, role)
|
a.consumeJob(job, role)
|
||||||
return
|
return
|
||||||
} else if followingAction == nil {
|
} else if followingAction == nil {
|
||||||
|
xlog.Info("Not following another action", "agent", a.Character.Name)
|
||||||
|
|
||||||
if !a.options.forceReasoning {
|
if !a.options.forceReasoning {
|
||||||
|
xlog.Info("Finish conversation with reasoning", "reasoning", reasoning, "agent", a.Character.Name)
|
||||||
|
|
||||||
msg := openai.ChatCompletionMessage{
|
msg := openai.ChatCompletionMessage{
|
||||||
Role: "assistant",
|
Role: "assistant",
|
||||||
Content: reasoning,
|
Content: reasoning,
|
||||||
@@ -590,6 +596,7 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// At this point can only be a reply action
|
// At this point can only be a reply action
|
||||||
|
xlog.Info("Computing reply", "agent", a.Character.Name)
|
||||||
|
|
||||||
// decode the response
|
// decode the response
|
||||||
replyResponse := action.ReplyResponse{}
|
replyResponse := action.ReplyResponse{}
|
||||||
@@ -645,6 +652,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
// )
|
// )
|
||||||
|
|
||||||
if !a.options.forceReasoning {
|
if !a.options.forceReasoning {
|
||||||
|
xlog.Info("No reasoning, return reply message", "reply", replyResponse.Message, "agent", a.Character.Name)
|
||||||
|
|
||||||
msg := openai.ChatCompletionMessage{
|
msg := openai.ChatCompletionMessage{
|
||||||
Role: "assistant",
|
Role: "assistant",
|
||||||
Content: replyResponse.Message,
|
Content: replyResponse.Message,
|
||||||
@@ -656,6 +665,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xlog.Info("Reasoning, ask LLM for a reply", "agent", a.Character.Name)
|
||||||
|
xlog.Debug("Conversation", "conversation", fmt.Sprintf("%+v", a.currentConversation))
|
||||||
msg, err := a.askLLM(ctx, append(a.currentConversation, openai.ChatCompletionMessage{
|
msg, err := a.askLLM(ctx, append(a.currentConversation, openai.ChatCompletionMessage{
|
||||||
Role: "system",
|
Role: "system",
|
||||||
Content: "The assistant needs to reply without using any tool.",
|
Content: "The assistant needs to reply without using any tool.",
|
||||||
@@ -678,6 +689,8 @@ func (a *Agent) consumeJob(job *Job, role string) {
|
|||||||
|
|
||||||
a.currentConversation = append(a.currentConversation, msg)
|
a.currentConversation = append(a.currentConversation, msg)
|
||||||
job.Result.SetResponse(msg.Content)
|
job.Result.SetResponse(msg.Content)
|
||||||
|
xlog.Info("Response from LLM", "response", msg.Content, "agent", a.Character.Name)
|
||||||
|
|
||||||
job.Result.Finish(nil)
|
job.Result.Finish(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,13 +231,8 @@ func (a *AgentPool) startAgentWithConfig(name string, config *AgentConfig) error
|
|||||||
|
|
||||||
a.agentStatus[name].addResult(state)
|
a.agentStatus[name].addResult(state)
|
||||||
a.Unlock()
|
a.Unlock()
|
||||||
xlog.Info(
|
xlog.Debug(
|
||||||
"Agent executed an action",
|
"Calling agent result callback",
|
||||||
"agent", name,
|
|
||||||
"reasoning", state.Reasoning,
|
|
||||||
"action", state.ActionCurrentState.Action.Definition().Name,
|
|
||||||
"params", state.ActionCurrentState.Params,
|
|
||||||
"result", state.Result,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
text := fmt.Sprintf(`Reasoning: %s
|
text := fmt.Sprintf(`Reasoning: %s
|
||||||
|
|||||||
Reference in New Issue
Block a user