From dfcbf6eee64fda4eafa4e60db949db78f703bc6d Mon Sep 17 00:00:00 2001 From: James Collins Date: Mon, 24 Apr 2023 15:24:57 -0700 Subject: [PATCH] Refactor/move singleton out of config module (#3161) --- .gitignore | 1 + autogpt/agent/agent_manager.py | 5 +++-- autogpt/config/__init__.py | 3 --- autogpt/config/config.py | 2 +- autogpt/logs.py | 3 ++- autogpt/memory/base.py | 3 ++- autogpt/{config => }/singleton.py | 0 autogpt/speech/base.py | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) rename autogpt/{config => }/singleton.py (100%) diff --git a/.gitignore b/.gitignore index 1ac55f6b..816cdb0c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ log-ingestion.txt logs *.log *.mp3 +mem.sqlite3 # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/autogpt/agent/agent_manager.py b/autogpt/agent/agent_manager.py index 9a62ef61..257127a3 100644 --- a/autogpt/agent/agent_manager.py +++ b/autogpt/agent/agent_manager.py @@ -1,10 +1,11 @@ """Agent manager for managing GPT agents""" from __future__ import annotations -from typing import List, Union +from typing import List -from autogpt.config.config import Config, Singleton +from autogpt.config.config import Config from autogpt.llm_utils import create_chat_completion +from autogpt.singleton import Singleton from autogpt.types.openai import Message diff --git a/autogpt/config/__init__.py b/autogpt/config/__init__.py index 726b6dcf..9bdd98e2 100644 --- a/autogpt/config/__init__.py +++ b/autogpt/config/__init__.py @@ -3,12 +3,9 @@ This module contains the configuration classes for AutoGPT. """ from autogpt.config.ai_config import AIConfig from autogpt.config.config import Config, check_openai_api_key -from autogpt.config.singleton import AbstractSingleton, Singleton __all__ = [ "check_openai_api_key", - "AbstractSingleton", "AIConfig", "Config", - "Singleton", ] diff --git a/autogpt/config/config.py b/autogpt/config/config.py index 600c3104..101f2919 100644 --- a/autogpt/config/config.py +++ b/autogpt/config/config.py @@ -8,7 +8,7 @@ from auto_gpt_plugin_template import AutoGPTPluginTemplate from colorama import Fore from dotenv import load_dotenv -from autogpt.config.singleton import Singleton +from autogpt.singleton import Singleton load_dotenv(verbose=True, override=True) diff --git a/autogpt/logs.py b/autogpt/logs.py index 35037404..9d661933 100644 --- a/autogpt/logs.py +++ b/autogpt/logs.py @@ -10,7 +10,8 @@ from logging import LogRecord from colorama import Fore, Style -from autogpt.config import Config, Singleton +from autogpt.config import Config +from autogpt.singleton import Singleton from autogpt.speech import say_text CFG = Config() diff --git a/autogpt/memory/base.py b/autogpt/memory/base.py index b6252464..83d80750 100644 --- a/autogpt/memory/base.py +++ b/autogpt/memory/base.py @@ -1,7 +1,8 @@ """Base class for memory providers.""" import abc -from autogpt.config import AbstractSingleton, Config +from autogpt.config import Config +from autogpt.singleton import AbstractSingleton cfg = Config() diff --git a/autogpt/config/singleton.py b/autogpt/singleton.py similarity index 100% rename from autogpt/config/singleton.py rename to autogpt/singleton.py diff --git a/autogpt/speech/base.py b/autogpt/speech/base.py index d74fa51b..7adcc37d 100644 --- a/autogpt/speech/base.py +++ b/autogpt/speech/base.py @@ -2,7 +2,7 @@ import abc from threading import Lock -from autogpt.config import AbstractSingleton +from autogpt.singleton import AbstractSingleton class VoiceBase(AbstractSingleton):