-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaster
More file actions
executable file
·122 lines (103 loc) · 3.08 KB
/
master
File metadata and controls
executable file
·122 lines (103 loc) · 3.08 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
#!/usr/bin/env bash
# ai.sh v50 — Hyper-Reasoning AI Orchestrator
# Local + Deepseek cloud, CLI + file-processing + dashboard
set -euo pipefail
IFS=$'\n\t'
BASE_DIR="$HOME/_/ai"
TMP_DIR="$BASE_DIR/tmp"
DB_FILE="$BASE_DIR/db/qbits.db"
mkdir -p "$TMP_DIR" "$(dirname "$DB_FILE")"
# Models
LOCAL_MODELS=("core" "loop" "2244" "coin" "code")
CLOUD_MODEL="deepseek-v3.1:671b-cloud"
# Defaults
TEMP_FACTOR="${TEMP_FACTOR:-0.5}"
RECUR_DEPTH="${RECUR_DEPTH:-5}"
MAX_LOOP="${MAX_LOOP:-10}"
# --- SQLite3 Setup ---
sqlite3 "$DB_FILE" "CREATE TABLE IF NOT EXISTS qbits (
agent TEXT,
prompt TEXT,
hash TEXT,
iteration INTEGER,
response TEXT,
timestamp REAL,
temp REAL
);"
# --- Utility Functions ---
hash_prompt(){ date +%s%N | sha256sum | cut -c1-64; }
log_qbit(){
local agent="$1" prompt="$2" hash="$3" iter="$4" resp="$5"
sqlite3 "$DB_FILE" \
"INSERT INTO qbits (agent,prompt,hash,iteration,response,timestamp,temp) VALUES ('$agent','$prompt','$hash',$iter,'$resp',$(date +%s),$TEMP_FACTOR);"
}
# --- File Processor Functions ---
scan_dir() {
local path="$1"
find "$path" -type f
}
read_file() {
local file="$1"
cat "$file"
}
backup_file() {
local file="$1"
cp "$file" "$file.bak"
}
replace_in_file() {
local file="$1" search="$2" replace="$3"
sed -i "s|$search|$replace|g" "$file"
}
process_files() {
local path="$1"
for f in $(scan_dir "$path"); do
backup_file "$f"
# example: replace placeholder with prompt info
replace_in_file "$f" "PLACEHOLDER" "$PROMPT_HASH"
# log to SQLite3
sqlite3 "$DB_FILE" "INSERT INTO qbits (agent,prompt,hash,iteration,response,timestamp,temp) VALUES ('fileproc','$f','$PROMPT_HASH',0,'processed',$(date +%s),$TEMP_FACTOR);"
done
}
# --- Python Neuro ---
run_python_neuro(){
local prompt="$1"
local hash=$(hash_prompt)
python3 "$BASE_DIR/ai.py" "$prompt" "$hash" "$TEMP_FACTOR" "$RECUR_DEPTH" &
PID_PY=$!
}
# --- Node.js Crew AI ---
run_node_ai(){
local prompt="$1" model="$2"
node "$BASE_DIR/ai.js" "$prompt" "$model" &
}
# --- Deepseek Cloud ---
run_deepseek_cloud(){
local prompt="$1"
node -e "
import fetch from 'node-fetch';
const res=await fetch('http://localhost:11434/api/generate',{
method:'POST',
headers:{'Content-Type':'application/json'},
body:JSON.stringify({model:'$CLOUD_MODEL',prompt:'$prompt',stream:true})
});
if(!res.ok){console.error('[CLOUD] Stream failed',res.status);}
else{console.log('[CLOUD] Stream complete.');}
" &
PID_CLOUD=$!
}
# --- Main ---
main(){
local prompt="${*:-}"
[[ -z "$prompt" ]] && read -rp "Enter human prompt: " prompt
PROMPT_HASH=$(hash_prompt)
# Parallel execution
run_python_neuro "$prompt"
for model in "${LOCAL_MODELS[@]}"; do run_node_ai "$prompt" "$model"; done
run_deepseek_cloud "$prompt"
# File-processing
process_files "$BASE_DIR"
# Wait
wait $PID_PY $PID_CLOUD
echo "[NEXUS] ✅ Hyper-reasoning complete. JSON/qbits updated in $TMP_DIR and SQLite3 DB."
}
main "$@"