A local model doesn’t need to solve difficult problems to save you work. Small, repetitive tasks—describing staged Git changes, naming a screenshot, or condensing an RSS article—are a more reasonable use case than asking it to program a complex function or answer any question.
The examples all follow the same workflow: a script collects a specific input, sends it to Ollama, and receives text. The API is queried on your own machine; there’s no need to send data to an external service. The scripts don’t replace review: a lengthy diff can confuse the model, a screenshot with small text may get an inaccurate name, and a summary may omit details.
flowchart TD
A["Local input"] --> B["Python script"]
B --> C["Local Ollama"]
C --> D["Generated text"]
D --> E["Review and use"]Set up Ollama and Python
Install Ollama and download a model compatible with each task. The XDA article describes using Qwen3-1.7B for text and Qwen3.5-2B for image analysis; it also mentions lightweight vision models such as SmolVLM2. Available model names may vary depending on your installation, so the model is passed through an environment variable instead of being hard-coded.
The examples use Ollama’s local generation API with responses returned all at once rather than streamed in chunks. Before running a script, make sure Ollama is running and set the exact name of the model you have installed. You can use the same model for both text tasks; for images, choose one with vision capabilities.
# Indicate the text model installed in Ollama.
export OLLAMA_MODEL='qwen3:1.7b'
# For the image script, indicate an installed vision model.
export OLLAMA_VISION_MODEL='qwen3.5:2b'
# Check which models your installation recognizes.
ollama list
The example values are configurable; they don’t guarantee that those exact identifiers are available in every installation. If the model shown by ollama list has a different name, use that name in the corresponding variable.
1. Suggest a message for staged changes
The following script reads only the diff Git has already staged, using git diff --staged. This avoids sending the entire repository to the model. The prompt requests a short message with a Conventional Commits prefix, such as fix, feat, or refactor, formats XDA uses as examples.
Save it as commit_message.py in the repository. The result is printed on screen: review it before using it as the final message. The model may misinterpret a change, especially if the diff is large or complicated.
import json
import os
import subprocess
import urllib.error
import urllib.request
MODEL = os.environ.get("OLLAMA_MODEL", "qwen3:1.7b")
API_URL = "http://localhost:11434/api/generate"
def generate(prompt):
payload = json.dumps({
"model": MODEL,
"prompt": prompt,
"stream": False,
}).encode("utf-8")
request = urllib.request.Request(
API_URL,
data=payload,
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=300) as response:
result = json.load(response)
return result["response"].strip()
try:
diff = subprocess.run(
["git", "diff", "--staged"],
check=True,
capture_output=True,
text=True,
).stdout
except subprocess.CalledProcessError as error:
raise SystemExit(error.stderr.strip() or "No se pudo ejecutar Git.")
if not diff.strip():
raise SystemExit("No hay cambios preparados con git add.")
prompt = (
"Escribe un único mensaje de commit breve en formato Conventional Commits. "
"Usa un prefijo como feat, fix o refactor cuando corresponda. "
"Describe solo los cambios que aparecen en esta diferencia.\n\n"
f"Diferencia preparada:\n{diff}"
)
try:
print(generate(prompt))
except (urllib.error.URLError, TimeoutError, KeyError, json.JSONDecodeError) as error:
raise SystemExit(f"No se pudo obtener una respuesta de Ollama: {error}")
If there’s nothing in the staging area, the program stops without calling the model. To try it out, stage a small change with git add and run python3 commit_message.py. The script doesn’t create a commit or modify files.
2. Give a screenshot a descriptive name
Interpreting an image requires a vision model. XDA describes an automation that watches a screenshot folder and suggests names such as home-assistant-temperature-dashboard.png. Here, we handle one image per run: the model returns a short name, and the program preserves the original extension.
Save the code as rename_screenshot.py. The request sends the image encoded in Base64 to the local endpoint. The script removes characters that don’t belong in a filename and avoids overwriting an existing file: the original screenshot remains intact if the suggested name is already taken.
import base64
import json
import os
import re
import sys
import urllib.request
from pathlib import Path
MODEL = os.environ.get("OLLAMA_VISION_MODEL", "qwen3.5:2b")
API_URL = "http://localhost:11434/api/generate"
def suggest_name(image_path):
image_data = base64.b64encode(image_path.read_bytes()).decode("ascii")
payload = json.dumps({
"model": MODEL,
"prompt": (
"Describe brevemente el contenido de esta captura como nombre "
"de archivo. Responde solo con palabras en minúsculas separadas "
"por guiones. No incluyas extensión ni explicación."
),
"images": [image_data],
"stream": False,
}).encode("utf-8")
request = urllib.request.Request(
API_URL,
data=payload,
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=300) as response:
result = json.load(response)
words = re.findall(r"[a-z0-9]+", result["response"].lower())
return "-".join(words[:8]).strip("-") or "captura"
if len(sys.argv) != 2:
raise SystemExit("Uso: python3 rename_screenshot.py ruta/a/captura.png")
source = Path(sys.argv[1])
if not source.is_file():
raise SystemExit(f"No se encuentra el archivo: {source}")
try:
base_name = suggest_name(source)
except (OSError, urllib.error.URLError, TimeoutError, KeyError, json.JSONDecodeError) as error:
raise SystemExit(f"No se pudo generar un nombre: {error}")
candidate = source.with_name(base_name + source.suffix.lower())
index = 2
while candidate.exists() and candidate != source:
candidate = source.with_name(f"{base_name}-{index}{source.suffix.lower()}")
index += 1
if candidate == source:
print(f"El archivo ya tiene ese nombre: {source.name}")
else:
source.rename(candidate)
print(f"Renombrado: {candidate.name}") Run python3 rename_screenshot.py ~/Pictures/captura.png, replacing the path with the one to your file. The model may struggle with unfamiliar interfaces or lots of tiny text; check the name and contents before organizing large batches. To automate a folder, you could integrate this same step into a process that detects new files, like the one described by XDA.
3. Summarize an RSS entry
The third example takes an RSS URL, downloads the XML, extracts the title and descriptive text, and requests a short summary. XDA says it used n8n to collect summaries from its feeds and mentions FreshRSS as another option for integrating local models. This script handles just one entry: you can run it with one URL at a time or connect it to your reader later.
The extraction handles common RSS elements with title, description, or content:encoded. Feeds don’t always have the same structure, so the code searches for these fields by local name and displays an error if it can’t find text to summarize.
import json
import os
import sys
import urllib.error
import urllib.request
import xml.etree.ElementTree as ET
MODEL = os.environ.get("OLLAMA_MODEL", "qwen3:1.7b")
API_URL = "http://localhost:11434/api/generate"
def local_name(tag):
return tag.rsplit("}", 1)[-1].split(":")[-1].lower()
def first_text(element, names):
for child in element.iter():
if local_name(child.tag) in names and child.text and child.text.strip():
return child.text.strip()
return ""
def summarize(text):
prompt = (
"Resume esta entrada en español en dos o tres frases. "
"Usa solo los datos del texto y no añadas información externa.\n\n"
f"{text}"
)
payload = json.dumps({
"model": MODEL,
"prompt": prompt,
"stream": False,
}).encode("utf-8")
request = urllib.request.Request(
API_URL,
data=payload,
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=300) as response:
result = json.load(response)
return result["response"].strip()
if len(sys.argv) != 2:
raise SystemExit("Uso: python3 summarize_rss.py URL_DEL_FEED")
feed_request = urllib.request.Request(
sys.argv[1], headers={"User-Agent": "LocalRSSSummary/1.0"}
)
try:
with urllib.request.urlopen(feed_request, timeout=30) as response:
root = ET.fromstring(response.read())
except (urllib.error.URLError, TimeoutError, ET.ParseError) as error:
raise SystemExit(f"No se pudo leer el feed: {error}")
entries = [element for element in root.iter() if local_name(element.tag) in {"item", "entry"}]
if not entries:
raise SystemExit("El feed no contiene entradas reconocibles.")
entry = entries[0]
title = first_text(entry, {"title"}) or "Entrada sin título"
body = first_text(entry, {"encoded", "description", "summary", "content"})
if not body:
raise SystemExit("La primera entrada no incluye texto para resumir.")
try:
summary = summarize(f"Título: {title}\n\nTexto: {body}")
except (urllib.error.URLError, TimeoutError, KeyError, json.JSONDecodeError) as error:
raise SystemExit(f"No se pudo resumir la entrada: {error}")
print(title)
print(summary)
The script summarizes the first entry it finds, not the entire feed, and depends on the content included in the feed itself. Some feeds provide only an excerpt; in that case, the model won’t be able to summarize the entire article. XDA describes a workflow using Qwen3-1.7B to generate summaries and collect them in a digest.
Common errors and limitations
A model that isn’t installed will usually cause an error when calling Ollama: check its name with ollama list and set the appropriate environment variable. If the server doesn’t respond, make sure Ollama is running. The examples use generous timeouts because a local model can take a while, especially with an image request or long text.
It’s best not to send huge diffs or feeds containing extremely long documents in a single request. XDA warns that the model may describe large or complex changes less accurately; it also observed that screenshots with lots of small text produced generic or inaccurate names. For RSS, the author used Qwen3-1.7B and collected the summaries in a digest. The model can condense articles into a few sentences with their main details.
The clearest limitation is the scope of the task: these automations request a specific transformation, not general judgment. Another How-To Geek analysis found slow and inaccurate answers when asking a broad question about IPv6 with a small local model, although it got a reasonable result when summarizing extensive documentation. Keeping the input and output focused is a practical choice, not a promise of accuracy.
Start with a short diff, a simple screenshot, and a feed you know. If the response saves a step and you can verify it quickly, you have a useful local automation; if it takes more corrections than the original task, narrow the scope of the request.
Sources: XDA, How-To Geek