跳到正文
DEV Community· noneofurbusiness·· 27 天前AI 評分39

SlothSort:以本地 AI 整理下載資料夾的智能體

SlothSort

AI 導讀

SlothSort 是一款透過 Ollama 在本地執行 Gemma 的 AI 智能體,可讀取支援的檔案內容、建議檔名並分類移動檔案;檔案不會被刪除,操作亦有記錄以供復原。Python 掃描支援的文字檔和 PDF,圖片則按檔名及副檔名分類,因為目前尚未實作 OCR。流程支援先預覽變更再套用,並可離線運作,無須每次請求都使用付費 AI API。

正文

noneofurbusiness

Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady Submission 🦥

🦥 SlothSort: A Lazy Way to Organize Your Downloads with Local AI

My submission for the Hacktoberfest Open-Source AI Challenge — Week 3: Slow and Steady.

What I Built

My Downloads folder was full of files with names like final_final_v2.zip and IMG_8841.png. I kept postponing the cleanup, so I built SlothSort — a local AI agent that organizes files for me.

It reads supported file contents, suggests meaningful filenames, and moves files into sensible folders. It never deletes files, and every operation is logged so I can undo changes.

Demo

How It Works

  1. Scan: Python scans files and extracts text from supported text files and PDFs. Images are currently classified using their filenames and extensions because OCR isn't implemented yet.
  2. Understand: Gemma runs locally through Ollama and returns structured JSON with a category, suggested filename, and explanation.
  3. Plan first: The plan command previews proposed changes without moving anything.
  4. Move and undo: The apply command moves files, while SQLite logs operations so undo can restore their previous locations.

Stack: Python, Gemma via Ollama, SQLite, and an optional PDF reader.

Why Open-Source AI Matters

Downloads folders can contain private documents, resumes, marksheets, and financial records. Uploading them to a cloud AI service just to organize files isn't ideal.

With Gemma running locally through Ollama, SlothSort can process supported content on my own machine. Once the model and dependencies are installed, the workflow can operate offline without requiring a paid AI API for every request.

Open-weight AI also gives me the freedom to experiment with models and customize the workflow while keeping greater control over my data.

Safety First

  • Dry-run mode previews changes before execution.
  • Files are moved, never deleted.
  • Model output is validated, and filenames are sanitized to prevent unsafe paths.
  • Rule-based fallback handles cases where Ollama is unavailable.
  • Automated tests cover dry-run, apply/undo, and invalid model output.

What Worked and What Didn't

  • Worked: [Add your actual test results: files correctly classified out of total files tested.]
  • Didn't: Without OCR, images are classified using filenames and extensions, so their actual contents aren't understood.
  • Next: Add OCR and a review step for uncertain classifications.

What I Learned

Building SlothSort showed me that reliable AI automation needs more than a good prompt. Validating model output, previewing changes, and supporting undo are essential for making an agent safer and more useful.

The goal: Spend less time organizing files and more time doing what matters. Let the sloth take care of the boring stuff. 🦥

devchallenges #hf26challenge #Gemma #Ollama

來源:DEV Community · dev.to