Skip to content

Commit

Permalink
Merge branch 'master' into feature/prompt-coverage-in-ci-pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
waynehamadi authored May 2, 2023
2 parents ed762ec + 0e1c0c5 commit 2df4e73
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions autogpt/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from autogpt.json_utils.json_fix_llm import fix_json_using_multiple_techniques
from autogpt.json_utils.utilities import LLM_DEFAULT_RESPONSE_FORMAT, validate_json
from autogpt.llm import chat_with_ai, create_chat_completion, create_chat_message
from autogpt.llm.token_counter import count_string_tokens
from autogpt.logs import logger, print_assistant_thoughts
from autogpt.speech import say_text
from autogpt.spinner import Spinner
Expand Down Expand Up @@ -233,6 +234,16 @@ def start_interaction_loop(self):
)
result = f"Command {command_name} returned: " f"{command_result}"

result_tlength = count_string_tokens(
str(command_result), cfg.fast_llm_model
)
memory_tlength = count_string_tokens(
str(self.summary_memory), cfg.fast_llm_model
)
if result_tlength + memory_tlength + 600 > cfg.fast_token_limit:
result = f"Failure: command {command_name} returned too much output. \
Do not execute this command again with the same arguments."

for plugin in cfg.plugins:
if not plugin.can_handle_post_command():
continue
Expand Down
2 changes: 1 addition & 1 deletion autogpt/json_utils/utilities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Utilities for the json_fixes package."""
import json
import os
import os.path
import re

from jsonschema import Draft7Validator
Expand Down
2 changes: 1 addition & 1 deletion autogpt/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def inspect_zip_for_modules(zip_path: str, debug: bool = False) -> list[str]:
result = []
with zipfile.ZipFile(zip_path, "r") as zfile:
for name in zfile.namelist():
if name.endswith("__init__.py"):
if name.endswith("__init__.py") and not name.startswith("__MACOSX"):
logger.debug(f"Found module '{name}' in the zipfile at: {name}")
result.append(name)
if len(result) == 0:
Expand Down

0 comments on commit 2df4e73

Please sign in to comment.