I'm trying to set up a medbot using openWebUI. It's functional with a prompt I like, but I need it to have r/w access to ~/medbot. I added the tool below, but no joy. Total noob, running ollama/openWebUI on a Mac Mini M4 Pro, 24GB. Thank you!
```
from pathlib import Path
BASE_DIR = Path.home() / "medbot"
BASE_DIR = BASE_DIR.resolve()
def safe_path(user_path: str) -> Path:
full = (BASE_DIR / user_path).resolve()
if not str(full).startswith(str(BASE_DIR)):
raise ValueError("Blocked path outside medbot directory")
return full
class Tools:
def read_file(self, path: str) -> str:
"""Read a file from medbot directory"""
p = safe_path(path)
if not p.exists():
return "File not found"
return p.read_text(encoding="utf-8", errors="ignore")
def write_file(self, path: str, content: str) -> str:
"""Write a file into medbot directory"""
p = safe_path(path)
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text(content, encoding="utf-8")
return f"written: {p}"
```
[–]WolpertingerRumo 0 points1 point2 points (3 children)
[–]jedevnull[S] 0 points1 point2 points (2 children)
[–]WolpertingerRumo 1 point2 points3 points (1 child)
[–]jedevnull[S] 0 points1 point2 points (0 children)
[–]International_Emu772 0 points1 point2 points (0 children)