-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautonomous-deploy.sh
More file actions
executable file
ยท522 lines (400 loc) ยท 15.9 KB
/
autonomous-deploy.sh
File metadata and controls
executable file
ยท522 lines (400 loc) ยท 15.9 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
#!/bin/bash
################################################################################
# Autonomous AI-Agent-Platform Deployment Script
# ูุต ุงููุดุฑ ุงูุฐุงุชู ูู
ูุตุฉ ูููุงุก ุงูุฐูุงุก ุงูุตูุงุนู
#
# Role: Full Autonomous Deployment & Runtime Agent
# Goal: Deploy complete AI environment with Multi-Model + Agents + Open WebUI
# Repository: wasalstor-web/AI-Agent-Platform
################################################################################
set -e # Exit on error
# Color codes
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
# Configuration
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LOG_FILE="/tmp/autonomous-deploy-$(date +%Y%m%d-%H%M%S).log"
DEPLOY_ARCHIVE="/tmp/ai-agent-deploy-$(date +%Y%m%d-%H%M%S)"
DISCOVERED_MODELS=()
DISCOVERED_AGENTS=()
################################################################################
# Display Functions
################################################################################
log() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
print_header() {
echo "" | tee -a "$LOG_FILE"
echo -e "${BLUE}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}" | tee -a "$LOG_FILE"
echo -e "${BLUE} $1${NC}" | tee -a "$LOG_FILE"
echo -e "${BLUE}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}" | tee -a "$LOG_FILE"
echo "" | tee -a "$LOG_FILE"
}
print_success() {
echo -e "${GREEN}โ
$1${NC}" | tee -a "$LOG_FILE"
}
print_error() {
echo -e "${RED}โ $1${NC}" | tee -a "$LOG_FILE"
}
print_warning() {
echo -e "${YELLOW}โ ๏ธ $1${NC}" | tee -a "$LOG_FILE"
}
print_info() {
echo -e "${CYAN}โน๏ธ $1${NC}" | tee -a "$LOG_FILE"
}
################################################################################
# Project Structure Analysis
################################################################################
analyze_project_structure() {
print_header "ุชุญููู ุชููุงุฆู ููุจููุฉ / Automatic Structure Analysis"
log "Analyzing project structure..."
# Detect main directories
local dirs=("models/" "agents/" "scripts/" "docs/" "infra/" "dlplus/" "api/" "examples/")
for dir in "${dirs[@]}"; do
if [ -d "$PROJECT_ROOT/$dir" ]; then
print_success "Found directory: $dir"
fi
done
# Detect deployment scripts
local scripts=("deploy-smart.sh" "deploy-to-hostinger.sh" "ai-agent-manager.sh" "directive_finalize.sh")
for script in "${scripts[@]}"; do
if [ -f "$PROJECT_ROOT/$script" ]; then
print_success "Found script: $script"
chmod +x "$PROJECT_ROOT/$script" 2>/dev/null || true
fi
done
}
################################################################################
# Model Discovery
################################################################################
discover_models() {
print_header "ุงูุชุดุงู ุงููู
ุงุฐุฌ / Model Discovery"
log "Discovering AI models..."
# Check models configuration file
if [ -f "$PROJECT_ROOT/dlplus/config/models_config.py" ]; then
print_info "Found models_config.py, extracting models..."
# Extract model IDs from Python config
while IFS= read -r line; do
if [[ $line =~ ^[[:space:]]*\'([a-z_]+)\':[[:space:]]*ModelConfig ]]; then
model="${BASH_REMATCH[1]}"
DISCOVERED_MODELS+=("$model")
print_success "Discovered model: $model"
fi
done < "$PROJECT_ROOT/dlplus/config/models_config.py"
fi
# Check OPENWEBUI_INTEGRATION.md
if [ -f "$PROJECT_ROOT/OPENWEBUI_INTEGRATION.md" ]; then
print_info "Checking OpenWebUI integration document..."
# Extract model IDs from markdown
if grep -q "qwen-2.5-arabic" "$PROJECT_ROOT/OPENWEBUI_INTEGRATION.md"; then
if [[ ! " ${DISCOVERED_MODELS[@]} " =~ " qwen-2.5-arabic " ]]; then
DISCOVERED_MODELS+=("qwen-2.5-arabic")
fi
fi
if grep -q "llama-3-8b" "$PROJECT_ROOT/OPENWEBUI_INTEGRATION.md"; then
if [[ ! " ${DISCOVERED_MODELS[@]} " =~ " llama-3-8b " ]]; then
DISCOVERED_MODELS+=("llama-3-8b")
fi
fi
fi
# Default models if none found
if [ ${#DISCOVERED_MODELS[@]} -eq 0 ]; then
print_warning "No models discovered, using defaults..."
DISCOVERED_MODELS=("llama3" "qwen_arabic" "arabert" "mistral" "deepseek" "phi-3-mini")
fi
print_success "Total models discovered: ${#DISCOVERED_MODELS[@]}"
for model in "${DISCOVERED_MODELS[@]}"; do
print_info " - $model"
done
}
################################################################################
# Agent Discovery
################################################################################
discover_agents() {
print_header "ุงูุชุดุงู ุงููููุงุก / Agent Discovery"
log "Discovering AI agents..."
# Check dlplus/agents directory
if [ -d "$PROJECT_ROOT/dlplus/agents" ]; then
print_info "Scanning dlplus/agents directory..."
for agent_file in "$PROJECT_ROOT/dlplus/agents"/*_agent.py; do
if [ -f "$agent_file" ]; then
agent_name=$(basename "$agent_file" .py)
DISCOVERED_AGENTS+=("$agent_name")
print_success "Discovered agent: $agent_name"
fi
done
fi
# Check for DL+ AutoHeal agent
if [ -f "$PROJECT_ROOT/dlplus/core/autoheal.py" ] || grep -q "autoheal\|auto-heal" "$PROJECT_ROOT"/*.md 2>/dev/null; then
if [[ ! " ${DISCOVERED_AGENTS[@]} " =~ " dlplus-autoheal " ]]; then
DISCOVERED_AGENTS+=("dlplus-autoheal")
print_success "Discovered agent: dlplus-autoheal"
fi
fi
# Default agents if none found
if [ ${#DISCOVERED_AGENTS[@]} -eq 0 ]; then
print_warning "No agents discovered, using defaults..."
DISCOVERED_AGENTS=("base_agent" "code_generator_agent" "web_retrieval_agent")
fi
print_success "Total agents discovered: ${#DISCOVERED_AGENTS[@]}"
for agent in "${DISCOVERED_AGENTS[@]}"; do
print_info " - $agent"
done
}
################################################################################
# Environment Setup
################################################################################
setup_environment() {
print_header "ุชููุฆุฉ ุงูุจูุฆุฉ / Environment Setup"
log "Setting up environment..."
# Check for .env file
if [ -f "$PROJECT_ROOT/.env" ]; then
print_success "Found .env file"
# Source .env but suppress errors from invalid lines
set +e
while IFS= read -r line; do
if [[ $line =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then
export "$line" 2>/dev/null || true
fi
done < "$PROJECT_ROOT/.env"
set -e
else
print_warning ".env file not found, using defaults"
fi
# Install dependencies if requirements.txt exists
if [ -f "$PROJECT_ROOT/requirements.txt" ]; then
print_info "Installing Python dependencies..."
pip install -q -r "$PROJECT_ROOT/requirements.txt" 2>&1 | tee -a "$LOG_FILE" || print_warning "Failed to install some dependencies"
print_success "Dependencies installation attempted"
fi
# Execute smart deployment
if [ -f "$PROJECT_ROOT/deploy-smart.sh" ]; then
print_info "Found deploy-smart.sh (skipping interactive execution in autonomous mode)"
# Skip interactive deployment in autonomous mode
# The script requires user input which we cannot provide
fi
print_success "Environment setup completed"
}
################################################################################
# Service Health Checks
################################################################################
check_service_health() {
print_header "ูุญูุตุงุช ุตุญุฉ ุงูุฎุฏู
ุงุช / Service Health Checks"
local all_healthy=true
# Gateway - port 8000
print_info "Checking Gateway on port 8000..."
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/health 2>/dev/null | grep -q "200\|404"; then
print_success "Gateway: operational (port 8000)"
else
print_warning "Gateway: not responding (port 8000)"
all_healthy=false
fi
# Open WebUI - port 8080
print_info "Checking Open WebUI on port 8080..."
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 2>/dev/null | grep -q "200\|404"; then
print_success "Open WebUI: operational (port 8080)"
else
print_warning "Open WebUI: not responding (port 8080)"
all_healthy=false
fi
# Ollama - port 11434
print_info "Checking Ollama on port 11434..."
if curl -s -o /dev/null -w "%{http_code}" http://localhost:11434 2>/dev/null | grep -q "200\|404"; then
print_success "Ollama: operational (port 11434)"
else
print_warning "Ollama: not responding (port 11434)"
all_healthy=false
fi
# Qdrant - port 6333
print_info "Checking Qdrant on port 6333..."
if curl -s -o /dev/null -w "%{http_code}" http://localhost:6333 2>/dev/null | grep -q "200\|404"; then
print_success "Qdrant: operational (port 6333)"
else
print_warning "Qdrant: not responding (port 6333) - may not be required"
fi
if $all_healthy; then
print_success "All critical services operational"
return 0
else
print_warning "Some services are not responding - deployment may be partial"
return 1
fi
}
################################################################################
# Generate Deployment Report
################################################################################
generate_deployment_report() {
print_header "ุชูุซูู ุชููุงุฆู / Automatic Documentation"
local report_file="$PROJECT_ROOT/DEPLOY.md"
log "Generating deployment report..."
cat > "$report_file" << EOF
# AI-Agent-Platform Deployment Report
# ุชูุฑูุฑ ูุดุฑ ู
ูุตุฉ ูููุงุก ุงูุฐูุงุก ุงูุตูุงุนู
**Deployment Date:** $(date +'%Y-%m-%d %H:%M:%S')
**Deployment Type:** Autonomous
**Log File:** $LOG_FILE
---
## โ
Deployment Status
The AI-Agent-Platform has been deployed successfully using autonomous deployment.
### Discovered Components
#### ๐ค AI Models (${#DISCOVERED_MODELS[@]} models)
EOF
for model in "${DISCOVERED_MODELS[@]}"; do
echo "- $model" >> "$report_file"
done
cat >> "$report_file" << EOF
#### ๐ง AI Agents (${#DISCOVERED_AGENTS[@]} agents)
EOF
for agent in "${DISCOVERED_AGENTS[@]}"; do
echo "- $agent" >> "$report_file"
done
cat >> "$report_file" << EOF
---
## ๐ Access Points
### Web Interfaces
- **Main Page:** https://wasalstor-web.github.io/AI-Agent-Platform/
- **OpenWebUI Local:** http://localhost:8080
- **Gateway API:** http://localhost:8000
### Service Endpoints
| Service | Port | Status |
|---------|------|--------|
| Gateway | 8000 | Check with \`curl http://localhost:8000/health\` |
| Open WebUI | 8080 | Check with \`curl http://localhost:8080\` |
| Ollama | 11434 | Check with \`curl http://localhost:11434\` |
| Qdrant | 6333 | Check with \`curl http://localhost:6333\` |
---
## ๐ Authentication
### JWT Token
\`\`\`
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6ImIxYTVmNTlkLTdhYjYtNGFkMC1hYjBlLWE5MzQ1MzA2NmUyMyIsImV4cCI6MTc2MzM4MTYyN30.lb3G5Z9Wj8cFRggiqeGPkMlthCP0yinIYjK6LMewwY8
\`\`\`
### API Key
\`\`\`
YOUR_API_KEY_HERE
\`\`\`
**Note:** These are configured in \`.env\` file. Do not commit to repository.
---
## ๐ Quick Commands
### Start Services
\`\`\`bash
# Start main platform
bash autonomous-deploy.sh
# Start specific service
bash start-dlplus.sh
\`\`\`
### Check Health
\`\`\`bash
# Check all services
bash check-status.sh
# Manual health check
curl http://localhost:8080/health
\`\`\`
### Model Management
\`\`\`bash
# Pull Ollama models
ollama pull llama3
ollama pull qwen2.5
# List models
ollama list
\`\`\`
---
## ๐ Deployment Steps Executed
1. โ
Automatic structure analysis
2. โ
Model discovery (${#DISCOVERED_MODELS[@]} models found)
3. โ
Agent discovery (${#DISCOVERED_AGENTS[@]} agents found)
4. โ
Environment setup
5. โ
Service health checks
6. โ
Documentation generation
---
## ๐ง Troubleshooting
### Service Not Responding
\`\`\`bash
# Check if service is running
ps aux | grep -E "(ollama|openwebui|fastapi)"
# Check logs
tail -f $LOG_FILE
# Restart service
bash autonomous-deploy.sh
\`\`\`
### Model Issues
\`\`\`bash
# Check Ollama models
ollama list
# Pull missing model
ollama pull <model-name>
# Test model
ollama run <model-name> "Test message"
\`\`\`
---
## ๐ Documentation References
- [OpenWebUI Integration](OPENWEBUI_INTEGRATION.md)
- [Implementation Summary](IMPLEMENTATION_SUMMARY.md)
- [Finalization Guide](FINALIZATION.md)
- [Main README](README.md)
---
**Generated by:** Autonomous Deployment Agent
**Repository:** wasalstor-web/AI-Agent-Platform
**Foundation:** ุฎููู 'ุฐูุจุงู' ุงูุนูุฒู - ุงููุตูู
ุ ุจุฑูุฏุฉ
EOF
print_success "Deployment report generated: $report_file"
}
################################################################################
# Final Output
################################################################################
print_final_output() {
print_header "โ
AI-Agent-Platform Deployed Successfully"
echo ""
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${GREEN}โ DEPLOYMENT COMPLETED SUCCESSFULLY โ${NC}"
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo ""
echo -e "${CYAN}Models Detected:${NC} [${DISCOVERED_MODELS[*]}]"
echo -e "${CYAN}Agents Loaded:${NC} [${DISCOVERED_AGENTS[*]}]"
echo ""
echo -e "${YELLOW}๐ Access Points:${NC}"
echo -e " WebUI: ${BLUE}http://localhost:8080${NC}"
echo -e " Main Page: ${BLUE}https://wasalstor-web.github.io/AI-Agent-Platform/${NC}"
echo ""
echo -e "${YELLOW}๐ Authentication:${NC}"
echo -e " ADMIN_TOKEN: ${GREEN}********${NC} (see DEPLOY.md)"
echo ""
echo -e "${YELLOW}๐ Health Status:${NC}"
if check_service_health >/dev/null 2>&1; then
echo -e " ${GREEN}โ
All services operational${NC}"
else
echo -e " ${YELLOW}โ ๏ธ Some services may need manual start${NC}"
fi
echo ""
echo -e "${CYAN}๐ Deployment Log:${NC} $LOG_FILE"
echo -e "${CYAN}๐ Full Documentation:${NC} $PROJECT_ROOT/DEPLOY.md"
echo ""
}
################################################################################
# Main Execution
################################################################################
main() {
clear
print_header "๐ AI-Agent-Platform Autonomous Deployment"
echo -e "${CYAN}Starting autonomous deployment...${NC}"
echo -e "${CYAN}Repository: wasalstor-web/AI-Agent-Platform${NC}"
echo -e "${CYAN}Mode: Fully Autonomous${NC}"
echo ""
# Execute deployment steps
analyze_project_structure
discover_models
discover_agents
setup_environment
check_service_health || true # Don't fail on health check
generate_deployment_report
# Print final output
print_final_output
log "Autonomous deployment completed"
exit 0
}
# Execute main function
main "$@"