Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions DRIVE/drive.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,18 @@ fn apply_file_write(path: str, content: str) {
// unavailable, so grounding never hard-depends on the embedding stack.
// Missing KB / no backend -> "" (graceful: edit still works, just unguided).
fn retrieve_recipes(instr: str) -> str {
let path = env("HOME") + "/.hx/packages/DRIVE/fix_recipes.txt"
// Resolve the package dir portably: DRIVE_PKG_DIR (exported by the bin/drive
// launcher of the released package) wins, else the in-repo/legacy install
// path. This keeps the KB + retriever findable regardless of install name
// (e.g. ~/.hx/packages/drive vs .../DRIVE).
let mut pkgdir = env("DRIVE_PKG_DIR")
if pkgdir.len() == 0 { pkgdir = env("HOME") + "/.hx/packages/DRIVE" }
let path = pkgdir + "/fix_recipes.txt"
let present = exec("test -f " + shq(path) + " && echo Y || echo N").trim()
if present != "Y" { return "" }
// STAGE 1+2 — proper hybrid retriever (graceful: empty/err -> inline scan)
let vpy = env("HOME") + "/.drive-rag-venv/bin/python"
let rag = env("HOME") + "/.hx/packages/DRIVE/rag_retrieve.py"
let rag = pkgdir + "/rag_retrieve.py"
let has_rag = exec("test -x " + shq(vpy) + " && test -f " + shq(rag) +
" && echo Y || echo N").trim()
if has_rag == "Y" {
Expand Down
5 changes: 3 additions & 2 deletions DRIVE/rag_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
"""
import sys, os, json, hashlib

KB = os.path.expanduser("~/.hx/packages/DRIVE/fix_recipes.txt")
CACHE = os.path.expanduser("~/.hx/packages/DRIVE/fix_recipes.emb.json")
_HERE = os.path.dirname(os.path.abspath(__file__)) # this script's dir = pkg root
KB = os.path.join(_HERE, "fix_recipes.txt") # KB ships beside this script
CACHE = os.path.join(_HERE, "fix_recipes.emb.json") # embedding cache (regenerable)
MODEL = os.environ.get("DRIVE_EMBED_MODEL", "intfloat/multilingual-e5-large")
EMBURL = os.environ.get("DRIVE_EMBED_URL", "").strip() # optional HTTP fallback
TOPK = int(os.environ.get("DRIVE_RAG_TOPK", "3"))
Expand Down
Loading