diff --git a/.gitignore b/.gitignore index d86afd88..03b867ac 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ Examples/Chatbot/DB/ /Sandbox/DB/ Sandbox/Logs/ + +docs/.obsidian/ diff --git a/Sandbox/.agentforge/settings/system.yaml b/Sandbox/.agentforge/settings/system.yaml index 84c06548..2ccca2e1 100644 --- a/Sandbox/.agentforge/settings/system.yaml +++ b/Sandbox/.agentforge/settings/system.yaml @@ -8,7 +8,7 @@ Logging: Folder: ./Logs Files: AgentForge: error - ModelIO: error + ModelIO: debug Results: error Paths: diff --git a/setup.py b/setup.py index fb69326d..df55cd2d 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def get_long_description(): setup( name="agentforge", - version="0.2.9", + version="0.2.11", description="AI-driven task automation system", author="John Smith, Ansel Anselmi", author_email="contact@agentforge.net", @@ -30,7 +30,7 @@ def get_long_description(): "termcolor~=2.3.0", "openai~=1.3.0", "chromadb~=0.4.23", - "sentence_transformers==2.2.2", + "sentence_transformers~=2.2.2", "anthropic==0.19.1", "google-api-python-client", "beautifulsoup4~=4.12.2", diff --git a/src/agentforge/agent.py b/src/agentforge/agent.py index ee212345..9ba8470a 100644 --- a/src/agentforge/agent.py +++ b/src/agentforge/agent.py @@ -150,10 +150,14 @@ def save_result(self): """ Saves the result of the language model generation into a specified storage. """ - try: - self.storage.save_memory(collection_name='Results', data=[self.result]) - except Exception as e: - self.logger.log(f"Error saving result: {e}", 'error') + if self.storage: + try: + self.storage.save_memory(collection_name='Results', data=[self.result]) + except Exception as e: + self.logger.log(f"Error saving result: {e}", 'error') + else: + self.logger.log(f"Storage is turned off - " + f"To turn on go to the storage.yaml file in the settings folder!", 'debug') def build_output(self): """ diff --git a/src/agentforge/config.py b/src/agentforge/config.py index 85be6dbc..f64eb7ef 100644 --- a/src/agentforge/config.py +++ b/src/agentforge/config.py @@ -7,7 +7,6 @@ class Config: _instance = None - _override_path = None def __new__(cls, *args, **kwargs): """ @@ -19,7 +18,7 @@ def __new__(cls, *args, **kwargs): """ if not cls._instance: cls._instance = super(Config, cls).__new__(cls, *args, **kwargs) - cls._instance.__init__() + # cls._instance.__init__() return cls._instance def __init__(self): @@ -27,17 +26,19 @@ def __init__(self): Initializes the Config object, setting up the project root and configuration path. Calls method to load configuration data from YAML files. """ - try: - self.project_root = self.find_project_root() - self.config_path = self.project_root / ".agentforge" + if not hasattr(self, 'is_initialized'): # Prevent re-initialization + self.is_initialized = True + try: + self.project_root = self.find_project_root() + self.config_path = self.project_root / ".agentforge" - # Placeholders for the data the agent needs which is located in each respective YAML file - self.data = {} + # Placeholders for the data the agent needs which is located in each respective YAML file + self.data = {} - # Here is where we load the information from the YAML files to their corresponding attributes - self.load_all_configurations() - except Exception as e: - raise ValueError(f"Error during Config initialization: {e}") + # Here is where we load the information from the YAML files to their corresponding attributes + self.load_all_configurations() + except Exception as e: + raise ValueError(f"Error during Config initialization: {e}") @staticmethod def find_project_root(): @@ -50,14 +51,16 @@ def find_project_root(): Raises: FileNotFoundError: If the .agentforge directory cannot be found. """ + print(f"\n\nCurrent working directory: {os.getcwd()}") - script_dir = pathlib.Path(sys.argv[0]).parent + script_dir = pathlib.Path(sys.argv[0]).resolve().parent current_dir = script_dir while current_dir != current_dir.parent: potential_dir = current_dir / ".agentforge" - + print(f"Checking {potential_dir}") # Debugging output if potential_dir.is_dir(): + print(f"Found .agentforge directory at: {current_dir}") # Debugging output return current_dir current_dir = current_dir.parent diff --git a/src/agentforge/llm/anthropic.py b/src/agentforge/llm/anthropic.py index f0dc8e08..5f72a47d 100644 --- a/src/agentforge/llm/anthropic.py +++ b/src/agentforge/llm/anthropic.py @@ -19,13 +19,8 @@ def parse_prompts(prompts): """ prompt = [ { - "role": "user", - "content": [ - { - "type": "text", - "text": "".join(prompts[1:]) - } - ] + 'role': 'user', + 'content': ''.join(prompts[1:]) } ] @@ -71,7 +66,8 @@ def generate_text(self, prompts, **params): """ self.logger = Logger(name=params.pop('agent_name', 'NamelessAgent')) prompt = parse_prompts(prompts) - self.logger.log_prompt(f"System: {prompts[0]}\n\nUser: {prompt}") + print(f"Prompt: {prompt}\n\n") + self.logger.log_prompt(f"System: {prompts[0]}\n\nUser: {prompt[0]['content']}") # Will retry to get chat if a rate limit or bad gateway error is received from the chat response = None diff --git a/src/agentforge/utils/storage_interface.py b/src/agentforge/utils/storage_interface.py index be5831c9..914ea500 100644 --- a/src/agentforge/utils/storage_interface.py +++ b/src/agentforge/utils/storage_interface.py @@ -82,6 +82,9 @@ def initialize_storage(self): if self.storage_utils is None: storage_api = self.config.data['settings']['storage']['StorageAPI'] + if storage_api is None: + self.storage_utils = None + return if storage_api == 'ChromaDB': self.initialize_chroma() return