Skip to content

Commit

Permalink
Remove self feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Merwane Hamadi <[email protected]>
  • Loading branch information
erik-megarad authored and waynehamadi committed Jun 15, 2023
1 parent 5cf1ffb commit d777e21
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 376 deletions.
67 changes: 1 addition & 66 deletions autogpt/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
from autogpt.config import Config
from autogpt.config.ai_config import AIConfig
from autogpt.json_utils.utilities import extract_json_from_response, validate_json
from autogpt.llm.base import ChatSequence
from autogpt.llm.chat import chat_with_ai, create_chat_completion
from autogpt.llm.chat import chat_with_ai
from autogpt.llm.providers.openai import OPEN_AI_CHAT_MODELS
from autogpt.llm.utils import count_string_tokens
from autogpt.log_cycle.log_cycle import (
FULL_MESSAGE_HISTORY_FILE_NAME,
NEXT_ACTION_FILE_NAME,
PROMPT_SUPERVISOR_FEEDBACK_FILE_NAME,
SUPERVISOR_FEEDBACK_FILE_NAME,
USER_INPUT_FILE_NAME,
LogCycleHandler,
)
Expand Down Expand Up @@ -208,24 +205,6 @@ def signal_handler(signum, frame):
if console_input.lower().strip() == self.config.authorise_key:
user_input = "GENERATE NEXT COMMAND JSON"
break
elif console_input.lower().strip() == "s":
logger.typewriter_log(
"-=-=-=-=-=-=-= THOUGHTS, REASONING, PLAN AND CRITICISM WILL NOW BE VERIFIED BY AGENT -=-=-=-=-=-=-=",
Fore.GREEN,
"",
)
thoughts = assistant_reply_json.get("thoughts", {})
self_feedback_resp = self.get_self_feedback(
thoughts, self.config.fast_llm_model
)
logger.typewriter_log(
f"SELF FEEDBACK: {self_feedback_resp}",
Fore.YELLOW,
"",
)
user_input = self_feedback_resp
command_name = "self_feedback"
break
elif console_input.lower().strip() == "":
logger.warn("Invalid input format.")
continue
Expand Down Expand Up @@ -281,8 +260,6 @@ def signal_handler(signum, frame):
result = f"Could not execute command: {arguments}"
elif command_name == "human_feedback":
result = f"Human feedback: {user_input}"
elif command_name == "self_feedback":
result = f"Self feedback: {user_input}"
else:
for plugin in self.config.plugins:
if not plugin.can_handle_pre_command():
Expand Down Expand Up @@ -336,45 +313,3 @@ def _resolve_pathlike_command_args(self, command_args):
self.workspace.get_path(command_args[pathlike])
)
return command_args

def get_self_feedback(self, thoughts: dict, llm_model: str) -> str:
"""Generates a feedback response based on the provided thoughts dictionary.
This method takes in a dictionary of thoughts containing keys such as 'reasoning',
'plan', 'thoughts', and 'criticism'. It combines these elements into a single
feedback message and uses the create_chat_completion() function to generate a
response based on the input message.
Args:
thoughts (dict): A dictionary containing thought elements like reasoning,
plan, thoughts, and criticism.
Returns:
str: A feedback response generated using the provided thoughts dictionary.
"""
ai_role = self.ai_config.ai_role

feedback_prompt = f"Below is a message from me, an AI Agent, assuming the role of {ai_role}. whilst keeping knowledge of my slight limitations as an AI Agent Please evaluate my thought process, reasoning, and plan, and provide a concise paragraph outlining potential improvements. Consider adding or removing ideas that do not align with my role and explaining why, prioritizing thoughts based on their significance, or simply refining my overall thought process."
reasoning = thoughts.get("reasoning", "")
plan = thoughts.get("plan", "")
thought = thoughts.get("thoughts", "")
feedback_thoughts = thought + reasoning + plan

prompt = ChatSequence.for_model(llm_model)
prompt.add("user", feedback_prompt + feedback_thoughts)

self.log_cycle_handler.log_cycle(
self.ai_config.ai_name,
self.created_at,
self.cycle_count,
prompt.raw(),
PROMPT_SUPERVISOR_FEEDBACK_FILE_NAME,
)

feedback = create_chat_completion(prompt)

self.log_cycle_handler.log_cycle(
self.ai_config.ai_name,
self.created_at,
self.cycle_count,
feedback,
SUPERVISOR_FEEDBACK_FILE_NAME,
)
return feedback
8 changes: 1 addition & 7 deletions autogpt/app.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
""" Command and Control """
import json
from typing import Dict, List, Union
from typing import Dict

from autogpt.agent.agent import Agent
from autogpt.agent.agent_manager import AgentManager
from autogpt.command_decorator import command
from autogpt.commands.web_requests import scrape_links, scrape_text
from autogpt.models.command_registry import CommandRegistry
from autogpt.processing.text import summarize_text
from autogpt.speech import say_text
from autogpt.url_utils.validators import validate_url


def is_valid_int(value: str) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion autogpt/log_cycle/log_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
SUMMARY_FILE_NAME = "summary.txt"
SUPERVISOR_FEEDBACK_FILE_NAME = "supervisor_feedback.txt"
PROMPT_SUPERVISOR_FEEDBACK_FILE_NAME = "prompt_supervisor_feedback.json"
USER_INPUT_FILE_NAME = "triggering_prompt.txt"
USER_INPUT_FILE_NAME = "user_input.txt"


class LogCycleHandler:
Expand Down
4 changes: 2 additions & 2 deletions autogpt/models/base_open_ai_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ def handle_text_embedding(self, text: str) -> list:

def can_handle_user_input(self, user_input: str) -> bool:
"""This method is called to check that the plugin can
handle the triggering_prompt method.
handle the user_input method.
Args:
user_input (str): The user input.
Returns:
bool: True if the plugin can handle the triggering_prompt method."""
bool: True if the plugin can handle the user_input method."""
return False

def user_input(self, user_input: str) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/data/test_plugins/auto_gpt_guanaco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ def handle_text_embedding(self, text: str) -> list:

def can_handle_user_input(self, user_input: str) -> bool:
"""This method is called to check that the plugin can
handle the triggering_prompt method.
handle the user_input method.
Args:
user_input (str): The user input.
Returns:
bool: True if the plugin can handle the triggering_prompt method."""
bool: True if the plugin can handle the user_input method."""
return False

def user_input(self, user_input: str) -> str:
Expand Down
119 changes: 0 additions & 119 deletions tests/unit/test_browse_scrape_links.py

This file was deleted.

117 changes: 0 additions & 117 deletions tests/unit/test_browse_scrape_text.py

This file was deleted.

Loading

0 comments on commit d777e21

Please sign in to comment.