AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Fix summarization happening in first cycle (#4719)
merwanehamadi0b6fec4a28ae
diff --git a/autogpt/json_utils/utilities.py b/autogpt/json_utils/utilities.pyindex 0184887192..e492d30289 100644--- a/autogpt/json_utils/utilities.py+++ b/autogpt/json_utils/utilities.py@@ -67,29 +67,3 @@ def validate_json(logger.debug("The JSON object is valid.")return True---def validate_json_string(json_string: str, schema_name: str) -> dict | None:- """- :type schema_name: object- :param schema_name: str- :type json_object: object- """-- try:- json_loaded = json.loads(json_string)- if not validate_json(json_loaded, schema_name):- return None- return json_loaded- except:- return None---def is_string_valid_json(json_string: str, schema_name: str) -> bool:- """- :type schema_name: object- :param schema_name: str- :type json_object: object- """-- return validate_json_string(json_string, schema_name) is not Nonediff --git a/autogpt/memory/message_history.py b/autogpt/memory/message_history.pyindex be52412540..897cee15e7 100644--- a/autogpt/memory/message_history.py+++ b/autogpt/memory/message_history.py@@ -9,11 +9,7 @@ if TYPE_CHECKING:from autogpt.agent import Agentfrom autogpt.config import Config-from autogpt.json_utils.utilities import (- LLM_DEFAULT_RESPONSE_FORMAT,- extract_json_from_response,- is_string_valid_json,-)+from autogpt.json_utils.utilities import extract_json_from_responsefrom autogpt.llm.base import ChatSequence, Message, MessageRole, MessageTypefrom autogpt.llm.providers.openai import OPEN_AI_CHAT_MODELSfrom autogpt.llm.utils import count_string_tokens, create_chat_completion@@ -105,8 +101,8 @@ class MessageHistory:)result_message = messages[i + 1]try:- assert is_string_valid_json(- ai_message.content, LLM_DEFAULT_RESPONSE_FORMAT+ assert (+ extract_json_from_response(ai_message.content) != {}), "AI response is not a valid JSON object"assert result_message.type == "action_result"