feat: isolate Python dependencies for RAG scripts
This commit is contained in:
parent
a19c98a684
commit
01287b2cc0
5 changed files with 85 additions and 10 deletions
19
bin/atvctl
19
bin/atvctl
|
|
@ -5,6 +5,10 @@ QDRANT_URL="${QDRANT_URL:-http://192.168.0.153:6333}"
|
|||
OLLAMA_URL="${OLLAMA_URL:-http://192.168.0.106:11434}"
|
||||
EMBED_MODEL="${EMBED_MODEL:-nomic-embed-text}"
|
||||
|
||||
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
|
||||
PROJECT_ROOT="$(cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
||||
PROJECT_PYTHON="$PROJECT_ROOT/.venv/bin/python"
|
||||
|
||||
ROOT="/mnt/media/ATIVA_IA/knowledge"
|
||||
NEW_COLLECTION="ativa_knowledge"
|
||||
KEEP_COLLECTIONS=("open-webui_files" "open-webui_knowledge")
|
||||
|
|
@ -15,11 +19,18 @@ die() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
require_project_python() {
|
||||
if [[ ! -x "$PROJECT_PYTHON" ]]; then
|
||||
die "Interpretador do projeto ausente ou não executável: $PROJECT_PYTHON. Crie o ambiente com: cd \"$PROJECT_ROOT\" && python3.11 -m venv .venv && .venv/bin/python -m pip install -r requirements-scripts.txt"
|
||||
fi
|
||||
}
|
||||
|
||||
qdrant() {
|
||||
curl -fsS "$QDRANT_URL$@"
|
||||
}
|
||||
|
||||
status() {
|
||||
require_project_python
|
||||
echo "=== ATIVA IA ==="
|
||||
echo "Qdrant : $QDRANT_URL"
|
||||
echo "Ollama : $OLLAMA_URL"
|
||||
|
|
@ -29,7 +40,7 @@ status() {
|
|||
for c in "$NEW_COLLECTION" "${KEEP_COLLECTIONS[@]}" "${OLD_COLLECTIONS[@]}"; do
|
||||
tmp=$(mktemp "${TMPDIR:-/tmp}/atvctl-qdrant.XXXXXX") || die "Não foi possível criar arquivo temporário"
|
||||
if curl -fsS "$QDRANT_URL/collections/$c" >"$tmp" 2>/dev/null; then
|
||||
python3 - "$c" "$tmp" <<'PY'
|
||||
"$PROJECT_PYTHON" - "$c" "$tmp" <<'PY'
|
||||
import json, sys
|
||||
c=sys.argv[1]
|
||||
d=json.load(open(sys.argv[2]))
|
||||
|
|
@ -44,7 +55,8 @@ PY
|
|||
}
|
||||
|
||||
qdrant_info() {
|
||||
qdrant "/collections/$NEW_COLLECTION" | python3 -c '
|
||||
require_project_python
|
||||
qdrant "/collections/$NEW_COLLECTION" | "$PROJECT_PYTHON" -c '
|
||||
import json,sys
|
||||
d=json.load(sys.stdin)["result"]
|
||||
print(json.dumps({
|
||||
|
|
@ -81,7 +93,8 @@ reset_apply() {
|
|||
}
|
||||
|
||||
ingest_python() {
|
||||
python3 - "$ROOT" "$QDRANT_URL" "$OLLAMA_URL" "$EMBED_MODEL" "$NEW_COLLECTION" "$1" <<'PY'
|
||||
require_project_python
|
||||
"$PROJECT_PYTHON" - "$ROOT" "$QDRANT_URL" "$OLLAMA_URL" "$EMBED_MODEL" "$NEW_COLLECTION" "$1" <<'PY'
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue