Skip to content

Commit

Permalink
Merge pull request #109 from DataBassGit/dev
Browse files Browse the repository at this point in the history
AgentForge 0.5.0
  • Loading branch information
DataBassGit authored Feb 2, 2025
2 parents d10685d + 26944dd commit feabdd0
Show file tree
Hide file tree
Showing 172 changed files with 5,390 additions and 3,825 deletions.
64 changes: 29 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,49 +1,43 @@
# Virtual environments
/venv/
Config/api_keys.ini

# Configuration files
.env
Config/api_keys.ini

# IDE settings
.idea/

# Compiled Python files
__pycache__/
Logs/log.txt
*.pyc
/hiAGI-Dev.log

AgentForge.log
# Logs
Logs/
*.log
*Logs/
*logs/

src/agentforge.egg-info/
src/agentforge/persona/chatbot.json
src/agentforge/salience.py
# Database directories
*DB/
*db/

# Build and distribution files
build/
dist/
src/agentforge.egg-info/

Examples/API/Logs/
Examples/CustomAgents/Logs/
Examples/DB/
SalienceBot/Logs/
SalienceBot/db_path/
/SalienceBot/DB/
/SalienceBot/Tests/
/Examples/KG/DB/

/Examples/Dyn/DB/
/Examples/Dyn/Logs/
/Examples/Dyn/Tests/

Examples/CustomAgents/DB/
/SalienceBot/path/

Examples/Chatbot/DB/
/SalienceBot/Files/
/SalienceBot/Workspace/
/Examples/KG/DB/
/Sandbox/DB/
Sandbox/Logs/
docs/.obsidian/

# Documentation tools
docs/.obsidian/

Sandbox/Logs/
# Examples and sandbox
Examples/**/DB/
Examples/**/Logs/
Examples/**/Tests/
sandbox/**/DB/
sandbox/**/Logs/
sandbox/**/Tests/

Sandbox/modules/Logs/
# Specific files
AgentForge.log
src/agentforge/persona/chatbot.json
File renamed without changes.
9 changes: 0 additions & 9 deletions Sandbox/.agentforge/prompts/custom/TestoAgent.yaml

This file was deleted.

114 changes: 0 additions & 114 deletions Sandbox/.agentforge/settings/models.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions Sandbox/.agentforge/settings/system.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions Sandbox/CustomAgents/TestAgent.py

This file was deleted.

5 changes: 0 additions & 5 deletions Sandbox/CustomAgents/TestoAgent.py

This file was deleted.

17 changes: 0 additions & 17 deletions Sandbox/RunTestAgent.py

This file was deleted.

3 changes: 0 additions & 3 deletions Sandbox/modules/TestActions.py

This file was deleted.

40 changes: 31 additions & 9 deletions docs/Agents/AgentClass.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The `Agent` class is designed to:
- Provide essential attributes and methods for agent operation.
- Facilitate seamless integration with various workflows and data structures.
- Simplify the creation of custom agents through method overriding.
- Allow flexible naming of agents by accepting an optional `agent_name` parameter.

By subclassing the `Agent` class, developers can create custom agents that inherit default behaviors and override methods to implement specific functionalities.

Expand All @@ -23,7 +24,7 @@ By subclassing the `Agent` class, developers can create custom agents that inher

The `Agent` class utilizes several key attributes:

- **`agent_name`**: The name of the agent, typically set to the class name.
- **`agent_name`**: The name of the agent, set to the provided `agent_name` parameter or defaults to the class name if `agent_name` is not provided.
- **`logger`**: A logger instance initialized with the agent’s name for logging messages.
- **`config`**: An instance of the `Config` class that handles configuration loading.
- **`prompt_handling`**: An instance of the `PromptHandling` class for managing prompt templates.
Expand All @@ -37,28 +38,38 @@ The `Agent` class utilizes several key attributes:

```python
class Agent:
def __init__(self):
def __init__(self, agent_name: Optional[str] = None):
"""
Initializes an Agent instance, setting up its name, logger, data attributes, and agent-specific configurations.
It attempts to load the agent's configuration data and storage settings.
Args:
name (Optional[str]): The name of the agent. If not provided, the class name is used.
"""
self.agent_name: str = self.__class__.__name__
# Set agent_name to the provided name or default to the class name
self.agent_name: str = agent_name if agent_name is not None else self.__class__.__name__

# Initialize logger with the agent's name
self.logger: Logger = Logger(name=self.agent_name)

# Initialize other configurations and handlers
self.config = Config()
self.prompt_handling = PromptHandling()

# Initialize data attributes
self.data: Dict[str, Any] = {}
self.prompt: Optional[List[str]] = None
self.result: Optional[str] = None
self.output: Optional[str] = None

# Initialize agent_data if it hasn't been set already
if not hasattr(self, 'agent_data'): # Prevent re-initialization
self.agent_data: Optional[Dict[str, Any]] = None
```

**Explanation**:

- **`self.agent_name`**: Automatically set to the class name, ensuring consistency between the agent's name and its class.
- **`self.agent_name`**: Set to the provided `agent_name` parameter if given; otherwise, defaults to the class name. This allows for flexible naming of agents without needing to create separate subclasses.
- **`self.logger`**: Initialized with the agent's name for consistent logging.
- **`self.config`**: Loads the configuration settings for the agent and the system.
- **`self.prompt_handling`**: Manages the rendering and validation of prompt templates.
Expand Down Expand Up @@ -93,12 +104,12 @@ def run(self, **kwargs: Any) -> Optional[str]:
self.logger.log(f"\n{self.agent_name} - Running...", 'info')
self.load_data(**kwargs)
self.process_data()
self.generate_prompt()
self.render_prompt()
self.run_llm()
self.parse_result()
self.save_to_storage()
self.build_output()
self.data = {}
self.template_data = {}
self.logger.log(f"\n{self.agent_name} - Done!", 'info')
except Exception as e:
self.logger.log(f"Agent execution failed: {e}", 'error')
Expand Down Expand Up @@ -141,7 +152,7 @@ Understanding the following key concepts is essential for effectively utilizing
- Includes parameters (`params`) and prompt templates (`prompts`).
- Example:
```python
self.data.update({
self.prompt_data.update({
'params': self.agent_data.get('params').copy(),
'prompts': self.agent_data['prompts'].copy()
})
Expand All @@ -155,7 +166,7 @@ Understanding the following key concepts is essential for effectively utilizing
if self.agent_data['settings']['system'].get('PersonasEnabled'):
persona = self.agent_data.get('persona', {})
for key in persona:
self.data[key.lower()] = persona[key]
self.prompt_data[key.lower()] = persona[key]
```

3. **Storage Data**:
Expand Down Expand Up @@ -261,14 +272,24 @@ class CustomAgent(Agent):
- **Method**: `self.resolve_storage()`
- **Process**:
- Checks if storage is enabled in system settings.
- If enabled, initializes the storage instance and stores it in `self.agent_data['storage']`.
- Initializes the storage instance and stores it in `self.agent_data['storage']`, ensuring that `self.agent_data['storage']` exists even if storage is disabled.
- Example:
```python
def resolve_storage(self):
if not self.agent_data['settings']['system'].get('StorageEnabled'):
self.agent_data['storage'] = None
return
from .utils.ChromaUtils import ChromaUtils
self.agent_data['storage'] = ChromaUtils(self.agent_data['persona']['Name'])
```

### Saving to Storage

- **Method**: `self.save_to_storage()`
- **Usage**:
- Intended to be overridden to implement specific logic for saving data.
- Access the storage instance via `self.agent_data['storage']`.
- Even if storage is disabled, `self.agent_data['storage']` will be `None`, allowing for consistent handling in custom implementations.

---

Expand All @@ -281,6 +302,7 @@ By understanding the `Agent` class and its core components, you can harness the
- **Workflow**: Understand the sequence of methods executed in `run` and how they interact.
- **Data Handling**: Utilize `self.data` effectively to manage and manipulate data within your agent.
- **Customization**: Override methods as needed to implement custom behaviors.
- **Agent Naming**: Use the `name` parameter to assign custom names to agents without the need for subclassing.

---

Expand Down
Loading

0 comments on commit feabdd0

Please sign in to comment.