feat: Add presence heartbeat for Matrix online status
- matrix-gateway: POST /internal/matrix/presence/online endpoint - usePresenceHeartbeat hook with activity tracking - Auto away after 5 min inactivity - Offline on page close/visibility change - Integrated in MatrixChatRoom component
This commit is contained in:
110
services/node2-crewai/README.md
Normal file
110
services/node2-crewai/README.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# CrewAI для microDAO Node-2
|
||||
|
||||
## 🎯 Призначення
|
||||
|
||||
CrewAI використовується для формування команд агентів (10-35 агентів) на microDAO Node-2.
|
||||
|
||||
## 📁 Структура
|
||||
|
||||
```
|
||||
~/node2/crewai/
|
||||
├── agents/ # Визначення агентів
|
||||
│ └── example_agent.py
|
||||
├── crews/ # Формування команд
|
||||
│ └── example_crew.py
|
||||
├── tasks/ # Задачі для агентів
|
||||
├── tools/ # Інструменти для агентів
|
||||
├── config/ # Конфігурація
|
||||
│ └── node2_crewai_config.yaml
|
||||
└── requirements.txt # Залежності
|
||||
```
|
||||
|
||||
## 🚀 Швидкий старт
|
||||
|
||||
### 1. Встановити залежності
|
||||
|
||||
```bash
|
||||
cd ~/node2/crewai
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 2. Створити агентів
|
||||
|
||||
Коли отримаєте список агентів, створіть їх у `agents/`:
|
||||
|
||||
```python
|
||||
from crewai import Agent
|
||||
|
||||
my_agent = Agent(
|
||||
role="Agent Role",
|
||||
goal="Agent Goal",
|
||||
backstory="Agent Backstory",
|
||||
tools=[...],
|
||||
llm=... # Will use Swoper/Ollama
|
||||
)
|
||||
```
|
||||
|
||||
### 3. Створити команди (crews)
|
||||
|
||||
```python
|
||||
from crewai import Crew, Process
|
||||
|
||||
my_crew = Crew(
|
||||
agents=[agent1, agent2, ...],
|
||||
tasks=[task1, task2, ...],
|
||||
process=Process.sequential,
|
||||
verbose=True,
|
||||
memory=True
|
||||
)
|
||||
```
|
||||
|
||||
### 4. Запустити команду
|
||||
|
||||
```python
|
||||
result = my_crew.kickoff()
|
||||
```
|
||||
|
||||
## 🔗 Інтеграція з microDAO Node-2
|
||||
|
||||
### LLM Provider (Swoper/Ollama)
|
||||
|
||||
CrewAI буде використовувати Swoper через Ollama API:
|
||||
|
||||
```python
|
||||
from langchain_community.llms import Ollama
|
||||
|
||||
llm = Ollama(
|
||||
base_url="http://localhost:11434",
|
||||
model="deepseek-r1" # або інша модель
|
||||
)
|
||||
```
|
||||
|
||||
### Memory (RAG Router)
|
||||
|
||||
Агенти можуть використовувати локальну пам'ять через RAG Router:
|
||||
|
||||
```python
|
||||
from crewai_tools import tool
|
||||
|
||||
@tool("Local Memory Search")
|
||||
def local_memory_search(query: str) -> str:
|
||||
# Використовує RAG Router для пошуку
|
||||
...
|
||||
```
|
||||
|
||||
## 📋 Очікується
|
||||
|
||||
- Список агентів (10-35 агентів)
|
||||
- Призначення LLM для кожного агента
|
||||
- Структура команд (crews)
|
||||
|
||||
## ⏭️ Наступні кроки
|
||||
|
||||
1. Дочекатися списку агентів від користувача
|
||||
2. Створити агентів з CrewAI
|
||||
3. Сформувати команди
|
||||
4. Інтегрувати з NodeAgent
|
||||
5. Запустити команди агентів
|
||||
|
||||
|
||||
|
||||
247
services/node2-crewai/setup_crewai_node2.sh
Executable file
247
services/node2-crewai/setup_crewai_node2.sh
Executable file
@@ -0,0 +1,247 @@
|
||||
#!/bin/bash
|
||||
# Setup CrewAI for microDAO Node-2
|
||||
# CrewAI will be used for agent team formation and orchestration
|
||||
|
||||
set -e
|
||||
|
||||
echo "🚀 Setting up CrewAI for microDAO Node-2"
|
||||
echo "=================================================="
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
# Check if CrewAI service exists on Node-1
|
||||
CREWAI_CONTAINER="dagi-crewai"
|
||||
if docker ps --format "{{.Names}}" | grep -q "^${CREWAI_CONTAINER}$"; then
|
||||
echo -e "${GREEN}✅ CrewAI container found: ${CREWAI_CONTAINER}${NC}"
|
||||
CREWAI_URL="http://localhost:9010"
|
||||
else
|
||||
echo -e "${YELLOW}⚠️ CrewAI container not found. Will set up local CrewAI.${NC}"
|
||||
CREWAI_URL="http://localhost:9010"
|
||||
fi
|
||||
|
||||
# Create CrewAI directory for Node-2
|
||||
CREWAI_DIR="$HOME/node2/crewai"
|
||||
mkdir -p "$CREWAI_DIR"/{agents,crews,tasks,tools,config}
|
||||
|
||||
echo -e "${GREEN}✅ Created CrewAI directory: ${CREWAI_DIR}${NC}"
|
||||
|
||||
# Create CrewAI configuration for Node-2
|
||||
cat > "$CREWAI_DIR/config/node2_crewai_config.yaml" << 'EOF'
|
||||
# CrewAI Configuration for microDAO Node-2
|
||||
|
||||
microdao_id: "microdao-node2"
|
||||
|
||||
# LLM Provider (via Swoper/Ollama)
|
||||
llm:
|
||||
provider: "ollama"
|
||||
base_url: "http://localhost:11434"
|
||||
models:
|
||||
default: "deepseek-r1" # Will be configured based on available models
|
||||
code: "qwen2.5-coder:72b"
|
||||
math: "deepseek-math:33b"
|
||||
vision: "qwen2-vl:32b"
|
||||
|
||||
# Memory (via RAG Router)
|
||||
memory:
|
||||
rag_router_url: "http://localhost:9401"
|
||||
qdrant_url: "http://localhost:6333"
|
||||
milvus_url: "http://localhost:19530"
|
||||
neo4j_url: "http://localhost:7474"
|
||||
|
||||
# Agent Team Structure
|
||||
agent_teams:
|
||||
system:
|
||||
description: "System agents for coordination and monitoring"
|
||||
agents: []
|
||||
|
||||
specialists:
|
||||
description: "Specialist agents for specific tasks"
|
||||
agents: []
|
||||
|
||||
custom:
|
||||
description: "Custom agents created by user"
|
||||
agents: []
|
||||
|
||||
# Crew Formation
|
||||
crews:
|
||||
default:
|
||||
name: "microdao-node2-default-crew"
|
||||
description: "Default crew for microDAO Node-2"
|
||||
agents: []
|
||||
tasks: []
|
||||
verbose: true
|
||||
memory: true
|
||||
|
||||
# Tools
|
||||
tools:
|
||||
enabled:
|
||||
- web_search
|
||||
- code_execution
|
||||
- file_operations
|
||||
- memory_operations
|
||||
|
||||
custom_tools_path: "~/node2/crewai/tools"
|
||||
|
||||
# Logging
|
||||
logging:
|
||||
level: "INFO"
|
||||
file: "~/node2/crewai/logs/crewai.log"
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Created CrewAI configuration${NC}"
|
||||
|
||||
# Create requirements file
|
||||
cat > "$CREWAI_DIR/requirements.txt" << 'EOF'
|
||||
crewai>=0.28.0
|
||||
crewai-tools>=0.1.0
|
||||
langchain>=0.1.0
|
||||
langchain-community>=0.0.20
|
||||
pydantic>=2.0.0
|
||||
pyyaml>=6.0.1
|
||||
httpx>=0.25.0
|
||||
EOF
|
||||
|
||||
echo -e "${GREEN}✅ Created requirements.txt${NC}"
|
||||
|
||||
# Create example agent template
|
||||
cat > "$CREWAI_DIR/agents/example_agent.py" << 'PYEOF'
|
||||
"""
|
||||
Example Agent Template for microDAO Node-2
|
||||
This is a template for creating agents with CrewAI
|
||||
"""
|
||||
|
||||
from crewai import Agent
|
||||
from crewai_tools import tool
|
||||
|
||||
# Example tool
|
||||
@tool("Local Memory Search")
|
||||
def local_memory_search(query: str) -> str:
|
||||
"""
|
||||
Search in local memory (Qdrant/Milvus/Neo4j) via RAG Router.
|
||||
|
||||
Args:
|
||||
query: Search query
|
||||
|
||||
Returns:
|
||||
Search results from local memory
|
||||
"""
|
||||
import httpx
|
||||
|
||||
rag_router_url = "http://localhost:9401"
|
||||
|
||||
try:
|
||||
response = httpx.post(
|
||||
f"{rag_router_url}/query",
|
||||
json={
|
||||
"query": query,
|
||||
"query_type": "vector_search",
|
||||
"limit": 10
|
||||
},
|
||||
timeout=30.0
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
results = response.json()
|
||||
return f"Found {results.get('count', 0)} results: {results.get('results', [])}"
|
||||
else:
|
||||
return f"Error: {response.status_code}"
|
||||
except Exception as e:
|
||||
return f"Error searching memory: {e}"
|
||||
|
||||
# Example agent
|
||||
example_agent = Agent(
|
||||
role="Example Agent",
|
||||
goal="Help with tasks using local memory and LLM",
|
||||
backstory="You are an agent in microDAO Node-2, with access to local memory and LLM inference.",
|
||||
tools=[local_memory_search],
|
||||
verbose=True,
|
||||
allow_delegation=False
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Example agent created successfully!")
|
||||
PYEOF
|
||||
|
||||
echo -e "${GREEN}✅ Created example agent template${NC}"
|
||||
|
||||
# Create crew template
|
||||
cat > "$CREWAI_DIR/crews/example_crew.py" << 'PYEOF'
|
||||
"""
|
||||
Example Crew Template for microDAO Node-2
|
||||
This is a template for creating crews with CrewAI
|
||||
"""
|
||||
|
||||
from crewai import Crew, Process
|
||||
from agents.example_agent import example_agent
|
||||
from crewai import Task
|
||||
|
||||
# Example task
|
||||
example_task = Task(
|
||||
description="Example task for microDAO Node-2",
|
||||
agent=example_agent,
|
||||
expected_output="Task completion result"
|
||||
)
|
||||
|
||||
# Example crew
|
||||
example_crew = Crew(
|
||||
agents=[example_agent],
|
||||
tasks=[example_task],
|
||||
process=Process.sequential,
|
||||
verbose=True,
|
||||
memory=True
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
result = example_crew.kickoff()
|
||||
print(f"Result: {result}")
|
||||
PYEOF
|
||||
|
||||
echo -e "${GREEN}✅ Created example crew template${NC}"
|
||||
|
||||
# Create setup script
|
||||
cat > "$CREWAI_DIR/setup.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
# Setup CrewAI environment for Node-2
|
||||
|
||||
echo "Setting up CrewAI for microDAO Node-2..."
|
||||
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Create virtual environment (optional)
|
||||
# python -m venv venv
|
||||
# source venv/bin/activate
|
||||
# pip install -r requirements.txt
|
||||
|
||||
echo "✅ CrewAI setup complete!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Create your agents in agents/"
|
||||
echo " 2. Create your crews in crews/"
|
||||
echo " 3. Run: python crews/your_crew.py"
|
||||
EOF
|
||||
|
||||
chmod +x "$CREWAI_DIR/setup.sh"
|
||||
|
||||
echo -e "${GREEN}✅ Created setup script${NC}"
|
||||
|
||||
echo -e "\n${GREEN}=================================================="
|
||||
echo "✅ CrewAI Setup Complete"
|
||||
echo "==================================================${NC}"
|
||||
echo ""
|
||||
echo "📁 CrewAI directory: ${CREWAI_DIR}"
|
||||
echo "📝 Configuration: ${CREWAI_DIR}/config/node2_crewai_config.yaml"
|
||||
echo ""
|
||||
echo "⏭️ Next steps:"
|
||||
echo " 1. Install dependencies: cd ${CREWAI_DIR} && pip install -r requirements.txt"
|
||||
echo " 2. Create your agents (you'll provide list later)"
|
||||
echo " 3. Create crews with your agents"
|
||||
echo " 4. Run crews for agent team formation"
|
||||
echo ""
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user