Vector memory revamp (part 1: refactoring) (#4208)

Additional changes:

* Improve typing

* Modularize message history memory & fix/refactor lots of things

* Fix summarization

* Move memory relevance calculation to MemoryItem & improve test

* Fix import warnings in web_selenium.py

* Remove `memory_add` ghost command

* Implement overlap in `split_text`

* Move memory tests into subdirectory

* Remove deprecated `get_ada_embedding()` and helpers

* Fix used token calculation in `chat_with_ai`

* Replace Message TypedDict by dataclass

* Fix AgentManager singleton issues in tests

---------

Co-authored-by: Auto-GPT-Bot <github-bot@agpt.co>
This commit is contained in:
Reinier van der Leer
2023-05-25 20:31:11 +02:00
committed by GitHub
parent 10489e0df2
commit bfbe613960
92 changed files with 7282 additions and 7989 deletions

View File

@@ -3,17 +3,16 @@ from unittest.mock import MagicMock
import pytest
from autogpt.agent import Agent
from autogpt.config import Config
from autogpt.config import AIConfig
@pytest.fixture
def agent():
ai_name = "Test AI"
memory = MagicMock()
full_message_history = []
next_action_count = 0
command_registry = MagicMock()
config = Config()
config = AIConfig()
system_prompt = "System prompt"
triggering_prompt = "Triggering prompt"
workspace_directory = "workspace_directory"
@@ -21,7 +20,6 @@ def agent():
agent = Agent(
ai_name,
memory,
full_message_history,
next_action_count,
command_registry,
config,
@@ -32,10 +30,10 @@ def agent():
return agent
def test_agent_initialization(agent):
def test_agent_initialization(agent: Agent):
assert agent.ai_name == "Test AI"
assert agent.memory == agent.memory
assert agent.full_message_history == []
assert agent.history.messages == []
assert agent.next_action_count == 0
assert agent.command_registry == agent.command_registry
assert agent.config == agent.config