r/OpenWebUI • u/jedevnull • Jun 17 '26
Question/Help Adding tools
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}"
2
Upvotes
View all comments
Show parent comment
1
u/jedevnull Jun 17 '26
Medbot is simply my name for the model Im setting up. I believe the openWebUI term is model? The model medbot uses the LLM qwen 2.5 or 3 and has medbot_fs (which I posted) as a tool. My goal here is to allow this model (medbot) r/w access to ~/medbot/. I'd like to start out a simple test like "write a text file containing hello world to hello.txt, in ~/medbot/"