▲ 1 r/ollama

Read/write access to local directory

I'm trying to set up a chatbot using ollama/openWebUI. It's functional with a prompt I like, but I need it to have r/w access to ~/medbot/ a directory on my Mac.

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}"
reddit.com
u/jedevnull — 19 days ago

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}"
reddit.com
u/jedevnull — 19 days ago
▲ 1 r/grok

Verified grok is capped?

Is grok now capped for verified X users?

"You've reached your limit of 40 Grok questions per 2 hours for now. Please check back later to continue, or upgrade to Premium+ now to continue the conversation."

I use grok a lot and this is a first for me.

reddit.com
u/jedevnull — 1 month ago