DEV Community

Waleed Shamhan
Waleed Shamhan

Posted on

AI Post Generator, Now Running on Local Open-Weight Models (Gemma 3 + Ollama)

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

AI-Post-Generator is a Python command-line tool that generates professional Arabic posts for WhatsApp and Telegram channels. I originally built it on a hosted API — and for this challenge I added a new mode that runs it on a local open-weight model (Gemma 3) through Ollama, with no hosted API involved.

Who would pay for it? Anyone who runs a channel and posts every day: channel owners, small businesses, media coordinators, and community managers. Writing fresh, consistent posts daily is the tedious task they all complain about — this tool turns a topic + a template into a ready post in seconds.

The problem it solves is threefold: the blank page (what do I post today?), consistency (same voice across every post), and cost/privacy (with the local mode, there is no per-post API bill and the channel's content never leaves the owner's machine).

Demo

Run it with the local open-weight model (default):

ollama pull gemma3
python main.py
# or explicitly:
python main.py --provider ollama --model gemma3
Enter fullscreen mode Exit fullscreen mode

The original hosted mode still works:

python main.py --provider openai
Enter fullscreen mode Exit fullscreen mode

Below is a real post generated by the tool running Gemma 3:1b locally via Ollama — topic "daily reading", template "morning motivation". The exact output is also saved in the repo as examples/gemma3_local_sample.txt:

صباح الخير يا أصدقائي! 📚

هل تبحث عن طريقة رائعة لتهدئة ذهنك، وتعزيز تركيزك، وفتح أبواب جديدة للمعرفة؟ القراءة اليومية هي الحل! ☀️

تذكروا، القراءة ليست مجرد قراءة، بل هي رحلة استكشافية، وتطوير الذات، وراحة البال. 🧘‍♀️

اكتشفوا قوة القراءة! 📖

شاركوا معنا أفكاركم حول القراءة اليومية. ما هي الكتب التي تحبون قراءتها؟ 🤔

دعونا نُشجع بعضكم البعض! 🤝

#صباح_الخير #تحفيز #إيجابية

Code

https://github.com/waleedshamhan2050-sys/AI-Post-Generator

The open-model mode is a --provider flag in main.py: get_client() points the same OpenAI-compatible client at the local Ollama server (http://localhost:11434/v1) instead of the hosted API, and the model defaults to gemma3 (configurable via OLLAMA_MODEL in .env or --model). The prompt, the JSON templates, and the saving logic are unchanged — only the provider changes.

How I Built It

  • Ollama for local inference — it exposes an OpenAI-compatible API, so the same client code works for both the hosted and the local path.
  • Gemma 3, an open-weight model, as the default local model.
  • JSON templates for each post type (announcement, quick tip, morning motivation, upcoming event, interactive question) with guiding examples.
  • python-dotenv for configuration (OLLAMA_MODEL, OLLAMA_BASE_URL, and the optional OPENAI_API_KEY for the hosted mode).

The key design decision: one codebase, two providers. The tool does not care where the model lives — the templates and the flow stay the same.

Why Does Open Innovation Matter?

This project is the reason I believe in open innovation:

  • Cost: a channel owner posting daily would pay per-post API fees forever. With a local open-weight model, the marginal cost of a post is zero — which is what makes the business actually work for small channels.
  • Privacy: channel content, business announcements, and audience ideas never leave the owner's machine. Nothing is sent to a third-party API.
  • No lock-in: no vendor can change the pricing, rate limits, or terms under you. If one model stops suiting you, you swap it — llama3.2, qwen2.5, mistral — without rewriting the tool.
  • Works offline: the tool runs on a laptop with no connection, which matters for users with unreliable internet.
  • Built for a niche: the templates are tuned for Arabic WhatsApp/Telegram channel style — a niche a general-purpose hosted API handles poorly out of the box.

Open weights made this possible. A closed API could never offer all five at once.

Prize Categories

  • Best Use of Gemma

Top comments (0)