Spaces:
Runtime error
Runtime error
nananie143
commited on
Upload folder using huggingface_hub
Browse files- Dockerfile +22 -15
- README.md +67 -35
- agentic_system.py +3 -2
- app.py +92 -54
- team_management.py +73 -12
Dockerfile
CHANGED
@@ -1,32 +1,39 @@
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
-
#
|
|
|
|
|
|
|
|
|
|
|
4 |
RUN apt-get update && apt-get install -y \
|
|
|
5 |
curl \
|
6 |
-
|
7 |
&& rm -rf /var/lib/apt/lists/*
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
# Set DNS configuration
|
12 |
-
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf && \
|
13 |
-
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
|
14 |
-
|
15 |
-
# Set network timeouts
|
16 |
-
ENV CURL_TIMEOUT=30
|
17 |
-
ENV REQUESTS_TIMEOUT=30
|
18 |
|
19 |
-
# Copy
|
20 |
COPY requirements.txt .
|
|
|
|
|
21 |
RUN pip install --no-cache-dir -r requirements.txt
|
22 |
|
23 |
# Copy application code
|
24 |
COPY . .
|
25 |
|
26 |
-
#
|
27 |
-
|
28 |
-
|
29 |
|
|
|
30 |
EXPOSE 7860
|
31 |
|
|
|
|
|
|
|
|
|
|
|
32 |
CMD ["python", "app.py"]
|
|
|
1 |
FROM python:3.10-slim
|
2 |
|
3 |
+
# Set environment variables
|
4 |
+
ENV PYTHONUNBUFFERED=1 \
|
5 |
+
DEBIAN_FRONTEND=noninteractive \
|
6 |
+
REQUESTS_TIMEOUT=30
|
7 |
+
|
8 |
+
# Install system dependencies
|
9 |
RUN apt-get update && apt-get install -y \
|
10 |
+
build-essential \
|
11 |
curl \
|
12 |
+
git \
|
13 |
&& rm -rf /var/lib/apt/lists/*
|
14 |
|
15 |
+
# Set working directory
|
16 |
+
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
# Copy requirements first to leverage Docker cache
|
19 |
COPY requirements.txt .
|
20 |
+
|
21 |
+
# Install Python dependencies
|
22 |
RUN pip install --no-cache-dir -r requirements.txt
|
23 |
|
24 |
# Copy application code
|
25 |
COPY . .
|
26 |
|
27 |
+
# Set up DNS configuration
|
28 |
+
RUN echo "nameserver 8.8.8.8" > /etc/resolv.conf && \
|
29 |
+
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
|
30 |
|
31 |
+
# Expose port
|
32 |
EXPOSE 7860
|
33 |
|
34 |
+
# Healthcheck
|
35 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
36 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
37 |
+
|
38 |
+
# Command to run the application
|
39 |
CMD ["python", "app.py"]
|
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: Advanced Reasoning System
|
3 |
-
emoji:
|
4 |
colorFrom: blue
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
@@ -10,63 +10,95 @@ pinned: false
|
|
10 |
license: mit
|
11 |
---
|
12 |
|
13 |
-
# Advanced Reasoning System
|
14 |
|
15 |
-
A sophisticated reasoning system that combines multiple strategies
|
16 |
|
17 |
## Features
|
18 |
|
19 |
-
-
|
20 |
-
- **Multiple Reasoning Strategies**:
|
21 |
- Chain of Thought
|
22 |
- Tree of Thoughts
|
23 |
- Meta Learning
|
|
|
24 |
- Recursive Reasoning
|
25 |
- Analogical Reasoning
|
26 |
-
- And more!
|
27 |
-
- **Adaptive Strategy Selection**: Dynamically chooses the best reasoning approach
|
28 |
-
- **GPU/CPU Flexibility**: Automatically uses GPU when available, falls back to CPU
|
29 |
-
- **Efficient Resource Usage**: Optimized for performance with configurable parameters
|
30 |
|
31 |
-
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
-
|
34 |
-
-
|
35 |
-
-
|
36 |
-
-
|
|
|
37 |
|
38 |
-
##
|
39 |
|
40 |
-
1.
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
50 |
|
51 |
-
##
|
|
|
|
|
52 |
|
53 |
```bash
|
54 |
-
|
55 |
-
|
56 |
```
|
57 |
|
58 |
-
##
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
## License
|
68 |
|
69 |
-
MIT License
|
70 |
|
71 |
## Files
|
72 |
- `app.py`: Main application with Gradio interface and API integration
|
|
|
1 |
---
|
2 |
+
title: Advanced Reasoning System 🤖
|
3 |
+
emoji: 🤖
|
4 |
colorFrom: blue
|
5 |
colorTo: purple
|
6 |
sdk: gradio
|
|
|
10 |
license: mit
|
11 |
---
|
12 |
|
13 |
+
# Advanced Reasoning System 🤖
|
14 |
|
15 |
+
A sophisticated multi-agent reasoning system that combines multiple strategies for advanced problem-solving.
|
16 |
|
17 |
## Features
|
18 |
|
19 |
+
- 🧠 Multiple Reasoning Strategies:
|
|
|
20 |
- Chain of Thought
|
21 |
- Tree of Thoughts
|
22 |
- Meta Learning
|
23 |
+
- Local LLM Integration
|
24 |
- Recursive Reasoning
|
25 |
- Analogical Reasoning
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
- 🤝 Multi-Agent System:
|
28 |
+
- Dynamic Team Formation
|
29 |
+
- Cross-Team Collaboration
|
30 |
+
- Resource Management
|
31 |
+
- Task Orchestration
|
32 |
|
33 |
+
- 🔄 Adaptive Learning:
|
34 |
+
- Performance Tracking
|
35 |
+
- Strategy Weight Adjustment
|
36 |
+
- Pattern Recognition
|
37 |
+
- Meta-Learning Integration
|
38 |
|
39 |
+
## Quick Start
|
40 |
|
41 |
+
1. **Environment Setup**:
|
42 |
+
```bash
|
43 |
+
python -m venv venv
|
44 |
+
source venv/bin/activate # On Windows: .\venv\Scripts\activate
|
45 |
+
pip install -r requirements.txt
|
46 |
+
```
|
47 |
|
48 |
+
2. **Configuration**:
|
49 |
+
```bash
|
50 |
+
cp .env.example .env
|
51 |
+
# Edit .env with your settings
|
52 |
+
```
|
53 |
|
54 |
+
3. **Run the Application**:
|
55 |
+
```bash
|
56 |
+
python app.py
|
57 |
+
```
|
58 |
|
59 |
+
## Docker Support
|
60 |
+
|
61 |
+
Build and run with Docker:
|
62 |
|
63 |
```bash
|
64 |
+
docker build -t advanced-reasoning .
|
65 |
+
docker run -p 7860:7860 advanced-reasoning
|
66 |
```
|
67 |
|
68 |
+
## API Endpoints
|
69 |
|
70 |
+
- `/`: Main interface
|
71 |
+
- `/health`: Health check endpoint
|
72 |
+
- `/api/process_query`: Process queries via API
|
73 |
+
|
74 |
+
## Components
|
75 |
+
|
76 |
+
1. **Reasoning Engine**:
|
77 |
+
- Unified reasoning combining multiple strategies
|
78 |
+
- Dynamic strategy selection
|
79 |
+
- Result synthesis
|
80 |
+
|
81 |
+
2. **Team Management**:
|
82 |
+
- Specialized teams (Coders, Business, Research, Trading)
|
83 |
+
- Cross-team collaboration
|
84 |
+
- Resource sharing
|
85 |
+
|
86 |
+
3. **Orchestration**:
|
87 |
+
- Task planning and decomposition
|
88 |
+
- Resource allocation
|
89 |
+
- Performance monitoring
|
90 |
+
|
91 |
+
## Contributing
|
92 |
+
|
93 |
+
1. Fork the repository
|
94 |
+
2. Create your feature branch
|
95 |
+
3. Commit your changes
|
96 |
+
4. Push to the branch
|
97 |
+
5. Create a Pull Request
|
98 |
|
99 |
## License
|
100 |
|
101 |
+
MIT License - see LICENSE file for details
|
102 |
|
103 |
## Files
|
104 |
- `app.py`: Main application with Gradio interface and API integration
|
agentic_system.py
CHANGED
@@ -27,6 +27,7 @@ from datetime import datetime
|
|
27 |
import uuid
|
28 |
from concurrent.futures import ThreadPoolExecutor
|
29 |
import numpy as np
|
|
|
30 |
|
31 |
from orchestrator import (
|
32 |
AgentOrchestrator,
|
@@ -35,8 +36,8 @@ from orchestrator import (
|
|
35 |
TaskPriority,
|
36 |
Task
|
37 |
)
|
38 |
-
from reasoning import ReasoningEngine, ReasoningMode
|
39 |
-
from meta_learning import MetaLearningStrategy
|
40 |
|
41 |
class AgentCapability(Enum):
|
42 |
"""Core capabilities of agents."""
|
|
|
27 |
import uuid
|
28 |
from concurrent.futures import ThreadPoolExecutor
|
29 |
import numpy as np
|
30 |
+
from collections import defaultdict
|
31 |
|
32 |
from orchestrator import (
|
33 |
AgentOrchestrator,
|
|
|
36 |
TaskPriority,
|
37 |
Task
|
38 |
)
|
39 |
+
from reasoning import UnifiedReasoningEngine as ReasoningEngine, StrategyType as ReasoningMode
|
40 |
+
from reasoning.meta_learning import MetaLearningStrategy
|
41 |
|
42 |
class AgentCapability(Enum):
|
43 |
"""Core capabilities of agents."""
|
app.py
CHANGED
@@ -19,7 +19,7 @@ from requests.adapters import HTTPAdapter, Retry
|
|
19 |
from agentic_system import AgenticSystem
|
20 |
from team_management import TeamManager
|
21 |
from orchestrator import AgentOrchestrator
|
22 |
-
from reasoning
|
23 |
|
24 |
# Configure logging
|
25 |
logging.basicConfig(level=logging.INFO)
|
@@ -29,31 +29,18 @@ logger = logging.getLogger(__name__)
|
|
29 |
TIMEOUT = int(os.getenv('REQUESTS_TIMEOUT', '30'))
|
30 |
RETRIES = 3
|
31 |
|
32 |
-
# Configure session with retries
|
33 |
-
session = requests.Session()
|
34 |
-
retries = Retry(total=RETRIES,
|
35 |
-
backoff_factor=1,
|
36 |
-
status_forcelist=[429, 500, 502, 503, 504])
|
37 |
-
session.mount('https://', HTTPAdapter(max_retries=retries))
|
38 |
-
session.mount('http://', HTTPAdapter(max_retries=retries))
|
39 |
-
|
40 |
def check_network():
|
41 |
"""Check network connectivity."""
|
42 |
try:
|
43 |
-
#
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
response.raise_for_status()
|
49 |
-
return True
|
50 |
-
except Exception as e:
|
51 |
-
logger.error(f"Network check failed: {e}")
|
52 |
return False
|
53 |
|
54 |
class AgentInterface:
|
55 |
"""Interface for the agentic system."""
|
56 |
-
|
57 |
def __init__(self):
|
58 |
"""Initialize the interface components."""
|
59 |
# Check network connectivity
|
@@ -66,66 +53,117 @@ class AgentInterface:
|
|
66 |
parallel_threshold=3,
|
67 |
learning_rate=0.1
|
68 |
)
|
69 |
-
|
|
|
|
|
70 |
async def process_query(self, message: str) -> str:
|
71 |
"""Process user query through the reasoning system."""
|
72 |
try:
|
73 |
-
#
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
'mode': 'analytical'
|
78 |
-
}
|
79 |
-
|
80 |
-
# Get response from reasoning engine
|
81 |
result = await self.reasoning_engine.reason(
|
82 |
query=message,
|
83 |
-
context=
|
84 |
)
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
except Exception as e:
|
89 |
logger.error(f"Error processing query: {e}")
|
90 |
return f"An error occurred: {str(e)}"
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
# Initialize interface
|
93 |
interface = AgentInterface()
|
94 |
|
95 |
# Create Gradio interface
|
96 |
-
with gr.Blocks(title="Advanced Reasoning System") as demo:
|
97 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
with gr.Row():
|
100 |
-
with gr.Column():
|
101 |
-
|
102 |
-
label="Your
|
103 |
-
placeholder="Enter your
|
104 |
lines=3
|
105 |
)
|
106 |
-
|
|
|
|
|
107 |
|
108 |
-
with gr.Column():
|
109 |
-
|
110 |
label="Response",
|
111 |
-
lines=
|
|
|
112 |
)
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
submit_btn.click(
|
115 |
fn=interface.process_query,
|
116 |
-
inputs=
|
117 |
-
outputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
)
|
119 |
-
|
120 |
-
# Start the server with health check endpoint
|
121 |
-
app = gr.mount_gradio_app(None, demo, path="/")
|
122 |
-
|
123 |
-
@app.get("/health")
|
124 |
-
async def health_check():
|
125 |
-
"""Health check endpoint."""
|
126 |
-
if check_network():
|
127 |
-
return {"status": "healthy"}
|
128 |
-
return {"status": "degraded", "reason": "network_issues"}
|
129 |
|
130 |
# Launch the interface
|
131 |
if __name__ == "__main__":
|
|
|
19 |
from agentic_system import AgenticSystem
|
20 |
from team_management import TeamManager
|
21 |
from orchestrator import AgentOrchestrator
|
22 |
+
from reasoning import UnifiedReasoningEngine
|
23 |
|
24 |
# Configure logging
|
25 |
logging.basicConfig(level=logging.INFO)
|
|
|
29 |
TIMEOUT = int(os.getenv('REQUESTS_TIMEOUT', '30'))
|
30 |
RETRIES = 3
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
def check_network():
|
33 |
"""Check network connectivity."""
|
34 |
try:
|
35 |
+
# Test connection to Hugging Face
|
36 |
+
response = requests.get('https://huggingface.co', timeout=TIMEOUT)
|
37 |
+
return response.status_code == 200
|
38 |
+
except requests.RequestException as e:
|
39 |
+
logger.warning(f"Network connectivity issue: {e}")
|
|
|
|
|
|
|
|
|
40 |
return False
|
41 |
|
42 |
class AgentInterface:
|
43 |
"""Interface for the agentic system."""
|
|
|
44 |
def __init__(self):
|
45 |
"""Initialize the interface components."""
|
46 |
# Check network connectivity
|
|
|
53 |
parallel_threshold=3,
|
54 |
learning_rate=0.1
|
55 |
)
|
56 |
+
self.team_manager = TeamManager(self.orchestrator)
|
57 |
+
self.system = AgenticSystem()
|
58 |
+
|
59 |
async def process_query(self, message: str) -> str:
|
60 |
"""Process user query through the reasoning system."""
|
61 |
try:
|
62 |
+
# Log incoming query
|
63 |
+
logger.info(f"Processing query: {message}")
|
64 |
+
|
65 |
+
# Get reasoning result
|
|
|
|
|
|
|
|
|
66 |
result = await self.reasoning_engine.reason(
|
67 |
query=message,
|
68 |
+
context={"timestamp": datetime.now().isoformat()}
|
69 |
)
|
70 |
+
|
71 |
+
# Format response
|
72 |
+
if result.success:
|
73 |
+
response = f"Answer: {result.answer}\nConfidence: {result.confidence:.2f}"
|
74 |
+
if result.meta_insights:
|
75 |
+
response += "\nInsights:\n" + "\n".join(f"- {insight}" for insight in result.meta_insights)
|
76 |
+
else:
|
77 |
+
response = "I apologize, but I couldn't process your query effectively. Please try rephrasing or providing more context."
|
78 |
+
|
79 |
+
return response
|
80 |
+
|
81 |
except Exception as e:
|
82 |
logger.error(f"Error processing query: {e}")
|
83 |
return f"An error occurred: {str(e)}"
|
84 |
|
85 |
+
def health_check(self) -> Dict[str, Any]:
|
86 |
+
"""Check system health."""
|
87 |
+
return {
|
88 |
+
"status": "healthy",
|
89 |
+
"network": check_network(),
|
90 |
+
"components": {
|
91 |
+
"orchestrator": self.orchestrator is not None,
|
92 |
+
"reasoning_engine": self.reasoning_engine is not None,
|
93 |
+
"team_manager": self.team_manager is not None,
|
94 |
+
"system": self.system is not None
|
95 |
+
},
|
96 |
+
"timestamp": datetime.now().isoformat()
|
97 |
+
}
|
98 |
+
|
99 |
# Initialize interface
|
100 |
interface = AgentInterface()
|
101 |
|
102 |
# Create Gradio interface
|
103 |
+
with gr.Blocks(title="Advanced Reasoning System", theme=gr.themes.Soft()) as demo:
|
104 |
+
gr.Markdown("""
|
105 |
+
# 🤖 Advanced Reasoning System
|
106 |
+
|
107 |
+
Welcome to the Advanced Reasoning System! This system combines multiple reasoning strategies:
|
108 |
+
- Chain of Thought
|
109 |
+
- Tree of Thoughts
|
110 |
+
- Meta Learning
|
111 |
+
- Local LLM
|
112 |
+
- And more!
|
113 |
+
|
114 |
+
Ask any question and the system will use its advanced reasoning capabilities to help you.
|
115 |
+
""")
|
116 |
|
117 |
with gr.Row():
|
118 |
+
with gr.Column(scale=4):
|
119 |
+
query_input = gr.Textbox(
|
120 |
+
label="Your Question",
|
121 |
+
placeholder="Enter your question here...",
|
122 |
lines=3
|
123 |
)
|
124 |
+
with gr.Row():
|
125 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
126 |
+
clear_btn = gr.Button("Clear")
|
127 |
|
128 |
+
with gr.Column(scale=6):
|
129 |
+
output = gr.Textbox(
|
130 |
label="Response",
|
131 |
+
lines=10,
|
132 |
+
interactive=False
|
133 |
)
|
134 |
|
135 |
+
# Add examples
|
136 |
+
gr.Examples(
|
137 |
+
examples=[
|
138 |
+
"How would you approach designing a scalable microservices architecture?",
|
139 |
+
"What are the key considerations for implementing a secure authentication system?",
|
140 |
+
"Can you help me understand the differences between various machine learning algorithms?",
|
141 |
+
],
|
142 |
+
inputs=query_input,
|
143 |
+
label="Example Questions"
|
144 |
+
)
|
145 |
+
|
146 |
+
# Event handlers
|
147 |
submit_btn.click(
|
148 |
fn=interface.process_query,
|
149 |
+
inputs=query_input,
|
150 |
+
outputs=output,
|
151 |
+
api_name="process_query"
|
152 |
+
)
|
153 |
+
clear_btn.click(
|
154 |
+
fn=lambda: ("", ""),
|
155 |
+
inputs=None,
|
156 |
+
outputs=[query_input, output],
|
157 |
+
api_name="clear"
|
158 |
+
)
|
159 |
+
|
160 |
+
# Add health check endpoint
|
161 |
+
demo.load(
|
162 |
+
fn=interface.health_check,
|
163 |
+
inputs=None,
|
164 |
+
outputs=None,
|
165 |
+
api_name="health"
|
166 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
# Launch the interface
|
169 |
if __name__ == "__main__":
|
team_management.py
CHANGED
@@ -22,8 +22,26 @@ from datetime import datetime
|
|
22 |
import uuid
|
23 |
from collections import defaultdict
|
24 |
|
25 |
-
from orchestrator import AgentOrchestrator, TaskPriority
|
26 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
class TeamType(Enum):
|
29 |
"""Specialized team types."""
|
@@ -70,7 +88,7 @@ class TeamManager:
|
|
70 |
def __init__(self, orchestrator: AgentOrchestrator):
|
71 |
self.orchestrator = orchestrator
|
72 |
self.teams: Dict[str, TeamProfile] = {}
|
73 |
-
self.agents: Dict[str, Dict[str, Agent]] = {} # team_id -> {agent_id -> Agent}
|
74 |
self.collaboration_network: Dict[str, CollaborationLink] = {}
|
75 |
self.shared_objectives: Dict[str, Set[str]] = defaultdict(set) # objective_id -> set of team_ids
|
76 |
self.lock = asyncio.Lock()
|
@@ -189,10 +207,14 @@ class TeamManager:
|
|
189 |
{
|
190 |
"role": AgentRole.COORDINATOR,
|
191 |
"capabilities": [
|
192 |
-
AgentCapability.
|
193 |
-
AgentCapability.
|
194 |
],
|
195 |
-
"personality": AgentPersonality.PROACTIVE
|
|
|
|
|
|
|
|
|
196 |
},
|
197 |
{
|
198 |
"role": AgentRole.EXECUTOR,
|
@@ -200,7 +222,11 @@ class TeamManager:
|
|
200 |
AgentCapability.EXECUTION,
|
201 |
AgentCapability.LEARNING
|
202 |
],
|
203 |
-
"personality": AgentPersonality.ANALYTICAL
|
|
|
|
|
|
|
|
|
204 |
}
|
205 |
]
|
206 |
|
@@ -214,7 +240,11 @@ class TeamManager:
|
|
214 |
AgentCapability.REASONING
|
215 |
],
|
216 |
"personality": AgentPersonality.CREATIVE,
|
217 |
-
"expertise": ["software_development", "system_design"]
|
|
|
|
|
|
|
|
|
218 |
}
|
219 |
])
|
220 |
elif team_type == TeamType.BUSINESS:
|
@@ -226,7 +256,11 @@ class TeamManager:
|
|
226 |
AgentCapability.LEARNING
|
227 |
],
|
228 |
"personality": AgentPersonality.PROACTIVE,
|
229 |
-
"expertise": ["business_strategy", "market_analysis"]
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
])
|
232 |
elif team_type == TeamType.RESEARCH:
|
@@ -238,7 +272,11 @@ class TeamManager:
|
|
238 |
AgentCapability.LEARNING
|
239 |
],
|
240 |
"personality": AgentPersonality.ANALYTICAL,
|
241 |
-
"expertise": ["research", "data_analysis"]
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
])
|
244 |
elif team_type == TeamType.TRADERS:
|
@@ -250,7 +288,11 @@ class TeamManager:
|
|
250 |
AgentCapability.REASONING
|
251 |
],
|
252 |
"personality": AgentPersonality.CAUTIOUS,
|
253 |
-
"expertise": ["trading", "risk_management"]
|
|
|
|
|
|
|
|
|
254 |
}
|
255 |
])
|
256 |
|
@@ -316,7 +358,7 @@ class TeamManager:
|
|
316 |
team_agents = self.agents[team_id]
|
317 |
|
318 |
# Calculate team progress
|
319 |
-
active_agents = sum(1 for agent in team_agents.values() if agent.state ==
|
320 |
completion_rate = sum(agent.get_task_completion_rate() for agent in team_agents.values()) / len(team_agents)
|
321 |
|
322 |
team_progress[team.name] = {
|
@@ -440,3 +482,22 @@ class TeamManager:
|
|
440 |
sum(link.strength for link in team_links) /
|
441 |
len(team_links) if team_links else 0.5
|
442 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
import uuid
|
23 |
from collections import defaultdict
|
24 |
|
25 |
+
from orchestrator import AgentOrchestrator, TaskPriority, AgentRole, AgentState
|
26 |
+
from reasoning import UnifiedReasoningEngine
|
27 |
+
|
28 |
+
# Agent capabilities and personality types
|
29 |
+
class AgentCapability(Enum):
|
30 |
+
"""Core capabilities of agents."""
|
31 |
+
REASONING = "reasoning"
|
32 |
+
LEARNING = "learning"
|
33 |
+
EXECUTION = "execution"
|
34 |
+
COORDINATION = "coordination"
|
35 |
+
MONITORING = "monitoring"
|
36 |
+
|
37 |
+
class AgentPersonality(Enum):
|
38 |
+
"""Different personality types for agents."""
|
39 |
+
ANALYTICAL = "analytical"
|
40 |
+
CREATIVE = "creative"
|
41 |
+
PRAGMATIC = "pragmatic"
|
42 |
+
COLLABORATIVE = "collaborative"
|
43 |
+
PROACTIVE = "proactive"
|
44 |
+
CAUTIOUS = "cautious"
|
45 |
|
46 |
class TeamType(Enum):
|
47 |
"""Specialized team types."""
|
|
|
88 |
def __init__(self, orchestrator: AgentOrchestrator):
|
89 |
self.orchestrator = orchestrator
|
90 |
self.teams: Dict[str, TeamProfile] = {}
|
91 |
+
self.agents: Dict[str, Dict[str, 'Agent']] = {} # team_id -> {agent_id -> Agent}
|
92 |
self.collaboration_network: Dict[str, CollaborationLink] = {}
|
93 |
self.shared_objectives: Dict[str, Set[str]] = defaultdict(set) # objective_id -> set of team_ids
|
94 |
self.lock = asyncio.Lock()
|
|
|
207 |
{
|
208 |
"role": AgentRole.COORDINATOR,
|
209 |
"capabilities": [
|
210 |
+
AgentCapability.REASONING,
|
211 |
+
AgentCapability.COORDINATION
|
212 |
],
|
213 |
+
"personality": AgentPersonality.PROACTIVE,
|
214 |
+
"profile": {
|
215 |
+
"name": "Coordinator",
|
216 |
+
"description": "Team coordinator"
|
217 |
+
}
|
218 |
},
|
219 |
{
|
220 |
"role": AgentRole.EXECUTOR,
|
|
|
222 |
AgentCapability.EXECUTION,
|
223 |
AgentCapability.LEARNING
|
224 |
],
|
225 |
+
"personality": AgentPersonality.ANALYTICAL,
|
226 |
+
"profile": {
|
227 |
+
"name": "Executor",
|
228 |
+
"description": "Task executor"
|
229 |
+
}
|
230 |
}
|
231 |
]
|
232 |
|
|
|
240 |
AgentCapability.REASONING
|
241 |
],
|
242 |
"personality": AgentPersonality.CREATIVE,
|
243 |
+
"expertise": ["software_development", "system_design"],
|
244 |
+
"profile": {
|
245 |
+
"name": "Developer",
|
246 |
+
"description": "Software developer"
|
247 |
+
}
|
248 |
}
|
249 |
])
|
250 |
elif team_type == TeamType.BUSINESS:
|
|
|
256 |
AgentCapability.LEARNING
|
257 |
],
|
258 |
"personality": AgentPersonality.PROACTIVE,
|
259 |
+
"expertise": ["business_strategy", "market_analysis"],
|
260 |
+
"profile": {
|
261 |
+
"name": "Planner",
|
262 |
+
"description": "Business planner"
|
263 |
+
}
|
264 |
}
|
265 |
])
|
266 |
elif team_type == TeamType.RESEARCH:
|
|
|
272 |
AgentCapability.LEARNING
|
273 |
],
|
274 |
"personality": AgentPersonality.ANALYTICAL,
|
275 |
+
"expertise": ["research", "data_analysis"],
|
276 |
+
"profile": {
|
277 |
+
"name": "Researcher",
|
278 |
+
"description": "Researcher"
|
279 |
+
}
|
280 |
}
|
281 |
])
|
282 |
elif team_type == TeamType.TRADERS:
|
|
|
288 |
AgentCapability.REASONING
|
289 |
],
|
290 |
"personality": AgentPersonality.CAUTIOUS,
|
291 |
+
"expertise": ["trading", "risk_management"],
|
292 |
+
"profile": {
|
293 |
+
"name": "Trader",
|
294 |
+
"description": "Trader"
|
295 |
+
}
|
296 |
}
|
297 |
])
|
298 |
|
|
|
358 |
team_agents = self.agents[team_id]
|
359 |
|
360 |
# Calculate team progress
|
361 |
+
active_agents = sum(1 for agent in team_agents.values() if agent.state == AgentState.BUSY)
|
362 |
completion_rate = sum(agent.get_task_completion_rate() for agent in team_agents.values()) / len(team_agents)
|
363 |
|
364 |
team_progress[team.name] = {
|
|
|
482 |
sum(link.strength for link in team_links) /
|
483 |
len(team_links) if team_links else 0.5
|
484 |
)
|
485 |
+
|
486 |
+
class Agent:
|
487 |
+
def __init__(self, profile: Dict, reasoning_engine: UnifiedReasoningEngine, meta_learning: bool):
|
488 |
+
self.profile = profile
|
489 |
+
self.reasoning_engine = reasoning_engine
|
490 |
+
self.meta_learning = meta_learning
|
491 |
+
self.state = AgentState.IDLE
|
492 |
+
|
493 |
+
def get_task_completion_rate(self):
|
494 |
+
# Implement task completion rate calculation
|
495 |
+
pass
|
496 |
+
|
497 |
+
def get_completed_task_count(self):
|
498 |
+
# Implement completed task count calculation
|
499 |
+
pass
|
500 |
+
|
501 |
+
def get_total_task_count(self):
|
502 |
+
# Implement total task count calculation
|
503 |
+
pass
|