-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlaunch_ragix.sh
More file actions
executable file
Β·403 lines (351 loc) Β· 14.3 KB
/
Copy pathlaunch_ragix.sh
File metadata and controls
executable file
Β·403 lines (351 loc) Β· 14.3 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
#!/bin/bash
# =============================================================================
# RAGIX Launcher
# =============================================================================
#
# Retrieval-Augmented Generative Interactive eXecution Agent
# A sovereign, local-first development assistant using Unix-RAG patterns.
#
# This launcher:
# 1. Initializes Conda
# 2. Creates/activates ragix-env environment
# 3. Checks and installs dependencies
# 4. Verifies Ollama and available LLM models
# 5. Launches the RAGIX GUI or selected component
#
# Author: Olivier Vitrac, PhD, HDR | olivier.vitrac@adservio.fr | Adservio | 2025-11-25
#
# Usage:
# ./launch_ragix.sh # Interactive menu
# ./launch_ragix.sh gui # Launch Streamlit GUI (port 8501)
# ./launch_ragix.sh web # Launch RAGIX-WEB FastAPI (port 8080)
# ./launch_ragix.sh demo # Run Claude demo
# ./launch_ragix.sh mcp # Start MCP server
# ./launch_ragix.sh test # Run LLM backend test
#
# =============================================================================
set -e
# =============================================================================
# Configuration
# =============================================================================
ENV_NAME="ragix-env"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Get version from ragix_core/version.py
get_version() {
if [ -f "$SCRIPT_DIR/ragix_core/version.py" ]; then
grep -oP '__version__\s*=\s*"\K[^"]+' "$SCRIPT_DIR/ragix_core/version.py" 2>/dev/null || echo "0.55.0"
else
echo "0.55.0"
fi
}
RAGIX_VERSION=$(get_version)
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
NC='\033[0m' # No Color
BOLD='\033[1m'
# =============================================================================
# Banner
# =============================================================================
print_banner() {
echo ""
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${CYAN}β${NC} ${CYAN}β${NC}"
echo -e "${CYAN}β${NC} ${BOLD}${GREEN}RAGIX${NC} v${RAGIX_VERSION} β Retrieval-Augmented Generative IX Agent ${CYAN}β${NC}"
echo -e "${CYAN}β${NC} ${CYAN}β${NC}"
echo -e "${CYAN}β${NC} ${MAGENTA}Sovereign β’ Local-First β’ Unix-RAG Patterns${NC} ${CYAN}β${NC}"
echo -e "${CYAN}β${NC} ${CYAN}β${NC}"
echo -e "${CYAN}β${NC} ${BLUE}Adservio Innovation Lab${NC} ${CYAN}β${NC}"
echo -e "${CYAN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""
}
# =============================================================================
# Conda Initialization
# =============================================================================
condainit() {
# Try common conda locations using ~ for portability
local CONDA_PATHS=(
~/anaconda3
~/miniconda3
~/miniforge3
/opt/conda
/opt/anaconda3
)
local CONDA_BASE=""
for path in "${CONDA_PATHS[@]}"; do
if [ -d "$path" ]; then
CONDA_BASE="$path"
break
fi
done
if [ -z "$CONDA_BASE" ]; then
echo -e "${RED}Error: Could not find Conda installation.${NC}"
echo "Searched: ${CONDA_PATHS[*]}"
return 1
fi
__conda_setup="$("$CONDA_BASE/bin/conda" 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$CONDA_BASE/etc/profile.d/conda.sh" ]; then
. "$CONDA_BASE/etc/profile.d/conda.sh"
else
export PATH="$CONDA_BASE/bin:$PATH"
fi
fi
unset __conda_setup
export CONDA_BASE
}
# =============================================================================
# Environment Management
# =============================================================================
check_env_exists() {
conda env list | grep -q "^${ENV_NAME} "
return $?
}
create_environment() {
echo -e "${YELLOW}Creating new conda environment: ${ENV_NAME}...${NC}"
if [ -f "$SCRIPT_DIR/environment.yaml" ]; then
conda env create -f "$SCRIPT_DIR/environment.yaml"
else
echo -e "${YELLOW}No environment.yaml found, creating minimal environment...${NC}"
conda create -n "$ENV_NAME" python=3.11 pip -y
fi
if [ $? -eq 0 ]; then
echo -e "${GREEN}β${NC} Environment created successfully"
return 0
else
echo -e "${RED}Error: Failed to create environment${NC}"
return 1
fi
}
install_dependencies() {
echo -e "${YELLOW}Checking/installing dependencies...${NC}"
# Install from requirements.txt
if [ -f "$SCRIPT_DIR/requirements.txt" ]; then
pip install -r "$SCRIPT_DIR/requirements.txt" --quiet
if [ $? -eq 0 ]; then
echo -e "${GREEN}β${NC} Dependencies installed"
else
echo -e "${YELLOW}β ${NC} Some dependencies may have failed to install"
fi
fi
# Install ragix_core in development mode
if [ -f "$SCRIPT_DIR/pyproject.toml" ] || [ -d "$SCRIPT_DIR/ragix_core" ]; then
pip install -e "$SCRIPT_DIR" --quiet 2>/dev/null || true
fi
}
# =============================================================================
# Ollama Checks
# =============================================================================
check_ollama() {
echo -e "${BLUE}[Ollama]${NC} Checking status..."
if curl -s http://localhost:11434/api/tags > /dev/null 2>&1; then
echo -e "${GREEN}β${NC} Ollama is running"
# Get model information
local MODELS_JSON=$(curl -s http://localhost:11434/api/tags)
local MODEL_COUNT=$(echo "$MODELS_JSON" | python3 -c "import sys, json; print(len(json.load(sys.stdin).get('models', [])))" 2>/dev/null)
if [ ! -z "$MODEL_COUNT" ] && [ "$MODEL_COUNT" -gt 0 ]; then
echo -e " Available models: ${GREEN}${MODEL_COUNT}${NC}"
echo ""
echo -e " ${BOLD}Models:${NC}"
echo "$MODELS_JSON" | python3 -c "
import sys, json
data = json.load(sys.stdin)
for m in data.get('models', [])[:10]: # Show max 10
name = m['name']
size_gb = m.get('size', 0) / 1e9
# Sovereignty indicator
print(f' π’ {name} ({size_gb:.1f} GB)')
" 2>/dev/null
if [ "$MODEL_COUNT" -gt 10 ]; then
echo -e " ... and $((MODEL_COUNT - 10)) more"
fi
else
echo -e "${YELLOW}β ${NC} No models found. Install one with:"
echo " ollama pull mistral"
echo " ollama pull granite3.1-moe:3b"
fi
return 0
else
echo -e "${YELLOW}β ${NC} Ollama not detected at localhost:11434"
echo ""
echo -e " To start Ollama:"
echo " ollama serve"
echo ""
echo -e " To install a model:"
echo " ollama pull mistral"
echo ""
return 1
fi
}
# =============================================================================
# Component Launchers
# =============================================================================
launch_gui() {
echo ""
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${GREEN}β${NC} Launching RAGIX Web Interface ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} URL: ${CYAN}http://localhost:8501${NC} ${GREEN}β${NC}"
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
echo ""
streamlit run "$SCRIPT_DIR/ragix_app.py"
}
launch_demo() {
echo ""
echo -e "${BLUE}Running Claude Demo...${NC}"
echo ""
python3 "$SCRIPT_DIR/examples/claude_demo.py"
}
launch_mcp() {
echo ""
echo -e "${BLUE}Starting MCP Server...${NC}"
echo ""
python3 "$SCRIPT_DIR/MCP/ragix_mcp_server.py"
}
launch_test() {
echo ""
echo -e "${BLUE}Running LLM Backend Test...${NC}"
echo ""
bash "$SCRIPT_DIR/examples/test_llm_backends.sh"
}
launch_ragix_web() {
echo ""
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${GREEN}β${NC} Launching RAGIX-WEB (FastAPI Advanced UI) ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} URL: ${CYAN}http://localhost:8080${NC} ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} Note: Creates config/cache in ~/.ragix/ ${GREEN}β${NC}"
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
echo ""
ragix-web
}
# =============================================================================
# Interactive Menu
# =============================================================================
show_menu() {
echo ""
echo -e "${BOLD}What would you like to do?${NC}"
echo ""
echo -e " ${GREEN}1)${NC} Launch Streamlit GUI ${CYAN}(Classic interface, port 8501)${NC}"
echo -e " ${GREEN}2)${NC} Run Claude Demo ${CYAN}(Feature demonstration)${NC}"
echo -e " ${GREEN}3)${NC} Start MCP Server ${CYAN}(For Claude Desktop/Code)${NC}"
echo -e " ${GREEN}4)${NC} Test LLM Backends ${CYAN}(Compare Ollama models)${NC}"
echo -e " ${GREEN}5)${NC} Python Shell ${CYAN}(Interactive RAGIX)${NC}"
echo -e " ${GREEN}6)${NC} Check Ollama Status ${CYAN}(View available models)${NC}"
echo -e " ${GREEN}7)${NC} Launch RAGIX-WEB ${CYAN}(Advanced FastAPI UI, port 8080)${NC}"
echo -e " ${GREEN}q)${NC} Quit"
echo ""
read -p "Select option [1-7, q]: " choice
case $choice in
1) launch_gui ;;
2) launch_demo ;;
3) launch_mcp ;;
4) launch_test ;;
5)
echo ""
echo -e "${BLUE}Starting Python shell with RAGIX...${NC}"
echo -e "${YELLOW}Try: from ragix_core import *${NC}"
echo ""
python3
;;
6)
echo ""
check_ollama
echo ""
show_menu
;;
7) launch_ragix_web ;;
q|Q)
echo ""
echo -e "${GREEN}Goodbye!${NC}"
exit 0
;;
*)
echo -e "${RED}Invalid option${NC}"
show_menu
;;
esac
}
# =============================================================================
# Main Execution
# =============================================================================
main() {
print_banner
# Step 1: Initialize Conda
echo -e "${YELLOW}[1/4]${NC} Initializing Conda..."
condainit
if ! command -v conda &> /dev/null; then
echo -e "${RED}Error: Conda not found after initialization.${NC}"
exit 1
fi
echo -e "${GREEN}β${NC} Conda initialized ($(conda --version))"
echo ""
# Step 2: Check/Create Environment
echo -e "${YELLOW}[2/4]${NC} Checking environment: ${ENV_NAME}..."
if ! check_env_exists; then
echo -e "${YELLOW}Environment not found. Creating...${NC}"
create_environment
fi
# Activate environment
conda activate "$ENV_NAME"
if [ $? -ne 0 ]; then
echo -e "${RED}Error: Failed to activate ${ENV_NAME} environment.${NC}"
exit 1
fi
echo -e "${GREEN}β${NC} Environment activated: ${ENV_NAME}"
echo -e " Python: $(python3 --version 2>&1 | head -1)"
echo ""
# Step 3: Check Dependencies
echo -e "${YELLOW}[3/4]${NC} Checking dependencies..."
install_dependencies
echo ""
# Step 4: Check Ollama
echo -e "${YELLOW}[4/4]${NC} Checking Ollama..."
check_ollama
echo ""
# Handle command-line arguments or show menu
case "${1:-}" in
gui)
launch_gui
;;
web)
launch_ragix_web
;;
demo)
launch_demo
;;
mcp)
launch_mcp
;;
test)
launch_test
;;
"")
show_menu
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
echo "Usage: $0 [gui|web|demo|mcp|test]"
exit 1
;;
esac
}
# Run main function
main "$@"
# Cleanup message (shown after Ctrl+C or exit)
echo ""
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo -e "${GREEN}β${NC} RAGIX session ended. ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} Thank you for using RAGIX! ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} ${GREEN}β${NC}"
echo -e "${GREEN}β${NC} ${BLUE}https://github.com/ovitrac/RAGIX${NC} ${GREEN}β${NC}"
echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}"
echo ""