From ddb7efa593dbdbea9b895b4448c49a6124358302 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Tue, 25 Jul 2023 18:08:50 +0200 Subject: [PATCH] Move misplaced log_cycle statements --- autogpt/agents/agent.py | 8 ++++++++ autogpt/agents/base.py | 9 +-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/autogpt/agents/agent.py b/autogpt/agents/agent.py index 93d3de86..563c6823 100644 --- a/autogpt/agents/agent.py +++ b/autogpt/agents/agent.py @@ -17,6 +17,7 @@ from autogpt.llm.base import Message from autogpt.llm.utils import count_string_tokens from autogpt.logs import logger from autogpt.logs.log_cycle import ( + CURRENT_CONTEXT_FILE_NAME, FULL_MESSAGE_HISTORY_FILE_NAME, NEXT_ACTION_FILE_NAME, USER_INPUT_FILE_NAME, @@ -109,6 +110,13 @@ class Agent(BaseAgent): self.history.raw(), FULL_MESSAGE_HISTORY_FILE_NAME, ) + self.log_cycle_handler.log_cycle( + self.ai_config.ai_name, + self.created_at, + self.cycle_count, + prompt.raw(), + CURRENT_CONTEXT_FILE_NAME, + ) return prompt def execute( diff --git a/autogpt/agents/base.py b/autogpt/agents/base.py index 029b07a0..e6b24be1 100644 --- a/autogpt/agents/base.py +++ b/autogpt/agents/base.py @@ -11,7 +11,7 @@ if TYPE_CHECKING: from autogpt.llm.base import ChatModelResponse, ChatSequence, Message from autogpt.llm.providers.openai import OPEN_AI_CHAT_MODELS, get_openai_command_specs from autogpt.llm.utils import count_message_tokens, create_chat_completion -from autogpt.logs import CURRENT_CONTEXT_FILE_NAME, logger +from autogpt.logs import logger from autogpt.memory.message_history import MessageHistory from autogpt.prompts.prompt import DEFAULT_TRIGGERING_PROMPT @@ -105,13 +105,6 @@ class BaseAgent(metaclass=ABCMeta): prompt: ChatSequence = self.construct_prompt(instruction) prompt = self.on_before_think(prompt, instruction) - self.log_cycle_handler.log_cycle( - self.ai_config.ai_name, - self.created_at, - self.cycle_count, - prompt.raw(), - CURRENT_CONTEXT_FILE_NAME, - ) raw_response = create_chat_completion( prompt, self.config,