mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-08 14:53:53 -05:00
Run Black and Isort
This commit is contained in:
@@ -56,7 +56,9 @@ class Agent:
|
||||
cfg = Config()
|
||||
self.ai_name = ai_name
|
||||
self.memory = memory
|
||||
self.summary_memory = "I was created." # Initial memory necessary to avoid hilucination
|
||||
self.summary_memory = (
|
||||
"I was created." # Initial memory necessary to avoid hilucination
|
||||
)
|
||||
self.last_memory_index = 0
|
||||
self.full_message_history = full_message_history
|
||||
self.next_action_count = next_action_count
|
||||
|
||||
@@ -155,12 +155,18 @@ def chat_with_ai(
|
||||
|
||||
# Insert Memories
|
||||
if len(full_message_history) > 0:
|
||||
newly_trimmed_messages, agent.last_memory_index = get_newly_trimmed_messages(
|
||||
(
|
||||
newly_trimmed_messages,
|
||||
agent.last_memory_index,
|
||||
) = get_newly_trimmed_messages(
|
||||
full_message_history=full_message_history,
|
||||
current_context=current_context,
|
||||
last_memory_index=agent.last_memory_index
|
||||
last_memory_index=agent.last_memory_index,
|
||||
)
|
||||
agent.summary_memory = update_running_summary(
|
||||
current_memory=agent.summary_memory,
|
||||
new_events=newly_trimmed_messages,
|
||||
)
|
||||
agent.summary_memory = update_running_summary(current_memory=agent.summary_memory, new_events=newly_trimmed_messages)
|
||||
current_context.insert(insertion_index, agent.summary_memory)
|
||||
|
||||
api_manager = ApiManager()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
from autogpt.config import Config
|
||||
@@ -5,8 +6,12 @@ from autogpt.llm.llm_utils import create_chat_completion
|
||||
|
||||
cfg = Config()
|
||||
|
||||
|
||||
def get_newly_trimmed_messages(
|
||||
full_message_history: List[Dict[str, str]], current_context: List[Dict[str, str]], last_memory_index: int) -> Tuple[List[Dict[str, str]], int]:
|
||||
full_message_history: List[Dict[str, str]],
|
||||
current_context: List[Dict[str, str]],
|
||||
last_memory_index: int,
|
||||
) -> Tuple[List[Dict[str, str]], int]:
|
||||
"""
|
||||
This function returns a list of dictionaries contained in full_message_history
|
||||
with an index higher than prev_index that are absent from current_context.
|
||||
@@ -21,7 +26,9 @@ def get_newly_trimmed_messages(
|
||||
int: The new index value for use in the next loop.
|
||||
"""
|
||||
# Select messages in full_message_history with an index higher than last_memory_index
|
||||
new_messages = [msg for i, msg in enumerate(full_message_history) if i > last_memory_index]
|
||||
new_messages = [
|
||||
msg for i, msg in enumerate(full_message_history) if i > last_memory_index
|
||||
]
|
||||
|
||||
# Remove messages that are already present in current_context
|
||||
new_messages_not_in_context = [
|
||||
@@ -34,7 +41,6 @@ def get_newly_trimmed_messages(
|
||||
last_message = new_messages_not_in_context[-1]
|
||||
new_index = full_message_history.index(last_message)
|
||||
|
||||
|
||||
return new_messages_not_in_context, new_index
|
||||
|
||||
|
||||
@@ -71,7 +77,7 @@ def update_running_summary(current_memory: str, new_events: List[Dict]) -> str:
|
||||
new_events.remove(event)
|
||||
|
||||
# This can happen at any point during execturion, not just the beginning
|
||||
if (len(new_events) == 0):
|
||||
if len(new_events) == 0:
|
||||
new_events = "Nothing new happened."
|
||||
|
||||
prompt = f'''Your task is to create a concise running summary of actions and information results in the provided text, focusing on key and potentially important information to remember.
|
||||
|
||||
Reference in New Issue
Block a user