-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_agentflow_simple.sh
More file actions
executable file
Β·299 lines (263 loc) Β· 8.45 KB
/
Copy pathsetup_agentflow_simple.sh
File metadata and controls
executable file
Β·299 lines (263 loc) Β· 8.45 KB
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
#!/bin/bash
# π AgentFlow - Simplified Setup Script
# Compatible with all bash versions
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
echo -e "${BLUE}π AgentFlow Setup Script (Simplified)${NC}"
echo -e "${BLUE}Setting up multi-model AI agent orchestration platform${NC}"
echo ""
# Function to print status messages
print_status() {
echo -e "${CYAN}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo -e "\n${PURPLE}=== $1 ===${NC}"
}
# Function to download and test models
setup_models() {
print_header "AI Models Setup"
# Model list (space-separated: name|company|size|specialty|icon)
MODELS=(
"llama3.2:1b|Meta|1.3GB|Conversation & Planning|π΅"
"gemma2:2b|Google|1.6GB|Speed & Efficiency|π"
"phi3.5:latest|Microsoft|2.2GB|Analysis & Problem Solving|π "
"moondream:latest|Independent|829MB|Vision & Multimodal|π£"
)
for model_info in "${MODELS[@]}"; do
# Parse model info
IFS='|' read -r model company size specialty icon <<< "$model_info"
print_status "${icon} Setting up $model ($company - $size)"
print_status " Specialty: $specialty"
# Check if model exists
if ollama list | grep -q "$model"; then
print_success " Model $model already exists"
else
print_status " Downloading $model..."
if ollama pull "$model"; then
print_success " Successfully downloaded $model"
else
print_error " Failed to download $model"
continue
fi
fi
# Test model
print_status " Testing $model..."
if timeout 30s echo "Hello" | ollama run "$model" > /dev/null 2>&1; then
print_success " Model $model is working correctly"
else
print_error " Model $model test failed, but continuing..."
fi
echo ""
done
}
# Function to create model configuration
create_model_config() {
print_header "Model Configuration Setup"
print_status "Creating model configuration files..."
# Create config directory
mkdir -p ./config
# Generate model config JSON
cat > ./config/models.json << 'EOF'
{
"models": {
"llama3.2:1b": {
"name": "Meta Llama 3.2",
"company": "Meta",
"size": "1.3GB",
"ram_usage": "1.5GB",
"specialty": "Conversation & Planning",
"description": "Optimized for natural dialogue, context understanding, and project planning",
"use_cases": ["Customer service", "Personal assistants", "Meeting facilitation", "Creative writing"],
"performance": {
"speed": 4,
"quality": 4,
"efficiency": 4
},
"branding": {
"color": "#1877F2",
"icon": "π΅",
"theme": "Meta Blue"
},
"optimal_for": ["conversations", "planning", "creative_tasks"],
"fallback_to": "gemma2:2b"
},
"gemma2:2b": {
"name": "Google Gemma 2",
"company": "Google",
"size": "1.6GB",
"ram_usage": "1.8GB",
"specialty": "Speed & Efficiency",
"description": "Ultra-fast responses with excellent efficiency for simple to moderate tasks",
"use_cases": ["FAQ bots", "Quick lookups", "Simple automation", "Real-time responses"],
"performance": {
"speed": 5,
"quality": 3,
"efficiency": 5
},
"branding": {
"color": "#4285F4",
"icon": "π",
"theme": "Google Multi-color"
},
"optimal_for": ["quick_responses", "simple_queries", "real_time"],
"fallback_to": "llama3.2:1b"
},
"phi3.5:latest": {
"name": "Microsoft Phi 3.5",
"company": "Microsoft",
"size": "2.2GB",
"ram_usage": "2.5GB",
"specialty": "Analysis & Problem Solving",
"description": "Advanced reasoning capabilities for complex problem solving and analysis",
"use_cases": ["Research agents", "Data analysis", "Technical reviews", "Mathematical reasoning"],
"performance": {
"speed": 3,
"quality": 5,
"efficiency": 3
},
"branding": {
"color": "#0078D4",
"icon": "π ",
"theme": "Microsoft Blue"
},
"optimal_for": ["analysis", "reasoning", "technical_tasks", "research"],
"fallback_to": "llama3.2:1b"
},
"moondream:latest": {
"name": "Moondream Vision",
"company": "Independent",
"size": "829MB",
"ram_usage": "1GB",
"specialty": "Vision & Multimodal",
"description": "Specialized in image understanding, OCR, and visual question answering",
"use_cases": ["Document processing", "Image analysis", "OCR", "Visual content creation"],
"performance": {
"speed": 3,
"quality": 4,
"efficiency": 4
},
"branding": {
"color": "#8B5CF6",
"icon": "π£",
"theme": "Vision Purple"
},
"optimal_for": ["image_analysis", "ocr", "visual_qa", "multimodal"],
"fallback_to": "llama3.2:1b"
}
},
"routing_rules": {
"conversation": "llama3.2:1b",
"planning": "llama3.2:1b",
"quick_response": "gemma2:2b",
"analysis": "phi3.5:latest",
"research": "phi3.5:latest",
"vision": "moondream:latest",
"multimodal": "moondream:latest",
"default": "llama3.2:1b"
},
"fallback_hierarchy": [
"llama3.2:1b",
"gemma2:2b",
"phi3.5:latest",
"moondream:latest"
]
}
EOF
print_success "Model configuration created at ./config/models.json"
}
# Function to run model tests
run_model_tests() {
print_header "Model Testing & Validation"
mkdir -p ./test_results
# Test each model
test_model "llama3.2:1b" "Create a brief project plan for building a mobile app"
test_model "gemma2:2b" "What is the capital of France?"
test_model "phi3.5:latest" "Solve this math problem step by step: What is 15% of 240?"
test_model "moondream:latest" "Describe what you can do with images"
print_success "Test results saved in ./test_results/"
}
# Helper function to test individual models
test_model() {
local model="$1"
local prompt="$2"
print_status "Testing $model with sample prompt..."
# Run test and measure time
start_time=$(date +%s)
if response=$(timeout 60s echo "$prompt" | ollama run "$model" 2>/dev/null); then
end_time=$(date +%s)
duration=$((end_time - start_time))
# Save test result
cat > "./test_results/${model//://}_test.json" << EOF
{
"model": "$model",
"prompt": "$prompt",
"response": "$response",
"response_time": "${duration}s",
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"status": "success"
}
EOF
print_success " $model: ${duration}s response time"
else
print_error " $model: Test failed"
cat > "./test_results/${model//://}_test.json" << EOF
{
"model": "$model",
"prompt": "$prompt",
"response": null,
"response_time": null,
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"status": "failed"
}
EOF
fi
}
# Main setup function
main() {
print_header "AgentFlow Quick Setup"
echo "This will:"
echo "β’ Download 4 specialized AI models"
echo "β’ Create configuration files"
echo "β’ Run basic tests"
echo ""
read -p "Continue? (y/N): " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Setup cancelled."
exit 0
fi
# Check if Ollama is running
if ! curl -s http://localhost:11434/api/tags > /dev/null; then
print_error "Ollama is not running. Please start it first:"
echo "ollama serve"
exit 1
fi
setup_models
create_model_config
run_model_tests
print_header "Setup Complete! π"
print_success "AgentFlow models are ready!"
echo ""
echo -e "${CYAN}Available Models:${NC}"
echo "π΅ llama3.2:1b - Meta Llama (Conversation & Planning)"
echo "π gemma2:2b - Google Gemma (Speed & Efficiency)"
echo "π phi3.5:latest - Microsoft Phi (Analysis & Problem Solving)"
echo "π£ moondream:latest - Vision AI (Image Analysis & Multimodal)"
echo ""
echo -e "${GREEN}Next: Run './start_backend.sh' to start the backend! π${NC}"
}
# Run main function
main "$@"