File size: 10,150 Bytes
c5828bc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | # Contributing to Multi-Agent Debate
Thank you for your interest in contributing to AGI-HEDGE-FUND! This document provides guidelines and instructions for contributing to the project.
## Table of Contents
- [Code of Conduct](#code-of-conduct)
- [Getting Started](#getting-started)
- [Development Environment](#development-environment)
- [Project Structure](#project-structure)
- [Contributing Code](#contributing-code)
- [Adding New Agents](#adding-new-agents)
- [Adding New LLM Providers](#adding-new-llm-providers)
- [Extending Diagnostic Tools](#extending-diagnostic-tools)
- [Documentation](#documentation)
- [Pull Request Process](#pull-request-process)
- [Core Development Principles](#core-development-principles)
## Code of Conduct
This project and everyone participating in it is governed by our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
## Getting Started
1. Fork the repository on GitHub
2. Clone your fork to your local machine
3. Set up the development environment
4. Make your changes
5. Submit a pull request
## Development Environment
To set up your development environment:
```bash
# Clone the repository
git clone https://github.com/your-username/agi-hedge-fund.git
cd agi-hedge-fund
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
```
## Project Structure
Understanding the project structure is important for effective contributions:
```
agi-hedge-fund/
βββ src/
β βββ agents/ # Agent implementations
β β βββ base.py # Base agent architecture
β β βββ graham.py # Value investor agent
β β βββ wood.py # Innovation investor agent
β β βββ ... # Other agent implementations
β βββ cognition/ # Recursive reasoning framework
β β βββ graph.py # LangGraph reasoning implementation
β β βββ memory.py # Temporal memory shell
β β βββ attribution.py # Decision attribution tracing
β β βββ arbitration.py # Consensus mechanisms
β βββ market/ # Market data interfaces
β β βββ sources/ # Data provider integrations
β β βββ environment.py # Market simulation environment
β β βββ backtesting.py # Historical testing framework
β βββ llm/ # Language model integrations
β β βββ models/ # Model-specific implementations
β β βββ router.py # Multi-model routing logic
β β βββ prompts/ # Structured prompting templates
β βββ utils/ # Utility functions
β β βββ diagnostics/ # Interpretability tools
β β βββ visualization.py # Performance visualization
β β βββ metrics.py # Performance metrics
β βββ portfolio/ # Portfolio management
β β βββ manager.py # Core portfolio manager
β β βββ allocation.py # Position sizing logic
β β βββ risk.py # Risk management
β βββ main.py # Entry point
βββ examples/ # Example usage scripts
βββ tests/ # Test suite
βββ docs/ # Documentation
βββ notebooks/ # Jupyter notebooks
```
## Contributing Code
We follow a standard GitHub flow:
1. Create a new branch from `main` for your feature or bugfix
2. Make your changes
3. Add tests for your changes
4. Run the test suite to ensure all tests pass
5. Format your code with Black
6. Submit a pull request to `main`
### Coding Style
We follow these coding standards:
- Use [Black](https://github.com/psf/black) for code formatting
- Use [isort](https://pycqa.github.io/isort/) for import sorting
- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) naming conventions
- Use type hints for function signatures
- Write docstrings in the Google style
To check and format your code:
```bash
# Format code with Black
black src tests examples
# Sort imports with isort
isort src tests examples
# Run type checking with mypy
mypy src
```
## Adding New Agents
To add a new philosophical agent:
1. Create a new file in `src/agents/` following existing agents as templates
2. Extend the `BaseAgent` class
3. Implement required methods: `process_market_data` and `generate_signals`
4. Add custom reasoning nodes to the agent's reasoning graph
5. Set appropriate memory decay and reasoning depth parameters
6. Add tests in `tests/agents/`
Example:
```python
from multi_agent_debate.agents.base import BaseAgent, AgentSignal
class MyNewAgent(BaseAgent):
def __init__(
self,
reasoning_depth: int = 3,
memory_decay: float = 0.2,
initial_capital: float = 100000.0,
model_provider: str = "anthropic",
model_name: str = "claude-3-sonnet-20240229",
trace_enabled: bool = False,
):
super().__init__(
name="MyNew",
philosophy="My unique investment philosophy",
reasoning_depth=reasoning_depth,
memory_decay=memory_decay,
initial_capital=initial_capital,
model_provider=model_provider,
model_name=model_name,
trace_enabled=trace_enabled,
)
# Configure reasoning graph
self._configure_reasoning_graph()
def _configure_reasoning_graph(self) -> None:
"""Configure the reasoning graph with custom nodes."""
# Add custom reasoning nodes
self.reasoning_graph.add_node(
"my_custom_analysis",
self._my_custom_analysis
)
# Configure reasoning flow
self.reasoning_graph.set_entry_point("my_custom_analysis")
def process_market_data(self, data):
# Implement custom market data processing
pass
def generate_signals(self, processed_data):
# Implement custom signal generation
pass
def _my_custom_analysis(self, state):
# Implement custom reasoning node
pass
```
## Adding New LLM Providers
To add a new LLM provider:
1. Extend the `ModelProvider` class in `src/llm/router.py`
2. Implement required methods
3. Update the `ModelRouter` to include your provider
4. Add tests in `tests/llm/`
Example:
```python
from multi_agent_debate.llm.router import ModelProvider, ModelCapability
class MyCustomProvider(ModelProvider):
"""Custom model provider."""
def __init__(self, api_key: Optional[str] = None):
"""
Initialize custom provider.
Args:
api_key: API key (defaults to environment variable)
"""
self.api_key = api_key or os.environ.get("MY_CUSTOM_API_KEY")
# Define models and capabilities
self.models = {
"my-custom-model": [
ModelCapability.REASONING,
ModelCapability.CODE_GENERATION,
ModelCapability.FINANCE,
],
}
def generate(self, prompt: str, **kwargs) -> str:
"""Generate text from prompt."""
# Implementation
pass
def get_available_models(self) -> List[str]:
"""Get list of available models."""
return list(self.models.keys())
def get_model_capabilities(self, model_name: str) -> List[ModelCapability]:
"""Get capabilities of a specific model."""
return self.models.get(model_name, [])
```
## Extending Diagnostic Tools
To add new diagnostic capabilities:
1. Add new shell patterns in `src/utils/diagnostics.py`
2. Implement detection logic
3. Update visualization tools to support the new pattern
4. Add tests in `tests/utils/`
Example:
```python
from multi_agent_debate.utils.diagnostics import ShellPattern
# Add new shell pattern
class MyCustomShellPattern(ShellPattern):
CUSTOM_PATTERN = "v999 CUSTOM-PATTERN"
# Configure shell pattern detection
shell_diagnostics.shell_patterns[MyCustomShellPattern.CUSTOM_PATTERN] = {
"pattern": r"custom.*pattern|unique.*signature",
"custom_threshold": 0.5,
}
# Implement detection logic
def _detect_custom_pattern(self, trace_type: str, content: Dict[str, Any]) -> bool:
content_str = json.dumps(content, ensure_ascii=False).lower()
pattern = self.shell_patterns[MyCustomShellPattern.CUSTOM_PATTERN]["pattern"]
# Check if pattern matches
if re.search(pattern, content_str, re.IGNORECASE):
# Add additional validation logic
return custom_validation_logic(content)
return False
```
## Documentation
Good documentation is crucial for the project. When contributing:
1. Update docstrings for any modified functions or classes
2. Update README.md if you're adding major features
3. Add examples for new features in the examples directory
4. Consider adding Jupyter notebooks for complex features
## Pull Request Process
1. Ensure your code follows our coding standards
2. Add tests for your changes
3. Update documentation as needed
4. Submit a pull request with a clear description of your changes
5. Address any feedback from reviewers
## Core Development Principles
When contributing to AGI-HEDGE-FUND, keep these core principles in mind:
1. **Transparency**: All agent decisions should be traceable and explainable
2. **Recursion**: Favor recursive approaches that enable deeper reasoning
3. **Attribution**: Maintain clear attribution chains for all decisions
4. **Interpretability**: Design for introspection and understanding
5. **Extensibility**: Make it easy to extend and customize the framework
By following these principles, you'll help maintain the project's coherence and quality.
Thank you for contributing to AGI-HEDGE-FUND!
|