Skip to content

Commit

Permalink
Merge pull request #98 from DataBassGit/dev
Browse files Browse the repository at this point in the history
Version 0.2.11
  • Loading branch information
DataBassGit authored Apr 2, 2024
2 parents fb9fa59 + d019112 commit b4ebdc6
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ Examples/Chatbot/DB/
/Sandbox/DB/

Sandbox/Logs/

docs/.obsidian/
2 changes: 1 addition & 1 deletion Sandbox/.agentforge/settings/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Logging:
Folder: ./Logs
Files:
AgentForge: error
ModelIO: error
ModelIO: debug
Results: error

Paths:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]",
Expand All @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions src/agentforge/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
29 changes: 16 additions & 13 deletions src/agentforge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class Config:
_instance = None
_override_path = None

def __new__(cls, *args, **kwargs):
"""
Expand All @@ -19,25 +18,27 @@ 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):
"""
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():
Expand All @@ -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
Expand Down
12 changes: 4 additions & 8 deletions src/agentforge/llm/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@ def parse_prompts(prompts):
"""
prompt = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "".join(prompts[1:])
}
]
'role': 'user',
'content': ''.join(prompts[1:])
}
]

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/agentforge/utils/storage_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b4ebdc6

Please sign in to comment.