A local, private AI agent that finds the right authority, the contact that actually works, and writes your complaint for you.
Not a chatbot. A LangGraph multi-agent pipeline that researches, verifies, drafts, and learns from what fails.
Quick start Β·
How it works Β·
Demo Β·
You have a real problem: stray dogs in your society, a broken sewer line, a wrong electricity bill. You search online, find five phone numbers, and call them one by one. Most are dead. One answers and[...]
Generic chatbots make this worse. They produce numbers that look right but have no source, and nobody can tell which ones are real.
You describe the problem in plain language, in any country, and the agent:
- Understands the issue, the city, and the country.
- Researches which government body usually handles it there.
- Collects contacts from official pages, with the source URL and date for every phone number and email.
- Reads community experiences (for example Reddit threads) to see which channels people say actually responded, and which sent them elsewhere.
- Ranks the contacts by confidence, and shows why.
- Drafts a clear, firm complaint letter or email, with the exact location, duration, impact, and a deadline.
- Learns: if you report that nothing worked, it excludes the failed numbers, follows any "try this office instead" hint, and runs a deeper search.
Everything runs on your own machine with a small local model, so your personal details never leave your computer.
- π Works in any country. Built around Pakistan, but the research is driven by data profiles, not hard-coded cities.
- π Private by design. Local LLM through Ollama (or llama.cpp). No personal data sent to a model provider.
- π§Ύ No invented numbers. Phone numbers and emails are extracted by code from fetched pages. The language model never writes a contact.
- π Evidence, not guesses. Every contact and claim carries a source URL and a date.
- π Confidence labels. High, Medium, or Low, with the reasons visible.
- π Failure-aware. Records what didn't work and re-researches with a wider search.
- π§ Memory. SQLite stores past complaints, outcomes, and failed channels.
- πͺΆ Runs on modest hardware. Designed for an 8 GB RAM, CPU-only machine.
The agent is a LangGraph state graph. The order of steps is fixed in code, so a small model can't take a wrong turn. The model is only used for narrow jobs[...]
flowchart TD
A(["User complaint"]) --> B["Intake agent: extract issue, city, country"]
B -->|"location missing"| Q["Ask the user"]
B --> C["Authority finder"]
C --> D["Researcher: official pages + community experiences"]
D --> E["Verifier: rank contacts by confidence"]
E --> F["Letter writer"]
F --> G["Reviewer: checklist score"]
G -->|"score low, retry once"| F
G --> H["Save + memory"]
H --> I(["Ranked contacts + draft letter"])
I -->|"none worked"| J["Feedback node"]
J -->|"exclude failed contacts, search deeper"| D
| Node | Uses the LLM? | Job |
|---|---|---|
| Intake | Yes (JSON) | Extract issue, location, duration, impact, country |
| Authority finder | Yes (small) | Propose which body handles the issue, with sources |
| Researcher | Search + LLM | Fetch pages, extract contacts with code, read experiences |
| Verifier | No | Score and rank contacts |
| Writer | Yes | Draft the letter or email |
| Reviewer | No | Checklist: location, duration, impact, deadline, length |
| Save + memory | No | Write the result to a file and to SQLite |
| Feedback | No | Record failures and redirect hints, trigger deeper search |
| Tier | Sources | Used for |
|---|---|---|
| Official | Government and city pages, citizen portals | Which body handles it, listed contacts |
| Community | Reddit, local forums, local news | Which channels worked, failed, or redirected |
| Weak signals | Quora, blogs | Low-weight hints only |
Open the demo video in a new tab
Demo video coming soon.
Example output (illustrative, not real contacts)
{
"status": "done",
"issue": "stray dogs in residential society",
"location": "Example Town, Example City, Example Country",
"authority": "Municipal animal control (example)",
"channels": [
{
"type": "phone",
"value": "+00 000 0000000",
"confidence": "Medium",
"reasons": ["listed on an official page", "2 community reports say it responded"],
"source": "https://example.gov/animal-control",
"found_on": "2026-01-01"
}
],
"letter": "Subject: Request for action on stray dogs in Example Town ...",
"review_score": 0.86,
"saved_file": "outputs/generated_letters/example.md"
}| Layer | Tools |
|---|---|
| Orchestration | LangGraph |
| LLM runtime | Ollama (default) or llama.cpp |
| Models | Small local models (see below) |
| Web research | Tavily (primary), DuckDuckGo (fallback), trafilatura / Jina Reader for page text |
| Contact extraction | phonenumbers plus regex, done in code |
| Memory | SQLite |
| API | FastAPI |
| Language | Python 3.10+ |
- Python 3.10 or newer
- 8 GB RAM is enough with a small model. No GPU required, though responses will be slower on CPU.
- About 3 to 5 GB of free disk space for one model
- A free Tavily API key for web search
Pick the smallest model that handles your language and returns valid JSON. Close heavy apps (browser tabs especially) while running the agent.
| Model | Notes |
|---|---|
gemma4:e2b |
Light and a good first try on 8 GB machines |
gemma3:4b |
Higher quality, but needs more free RAM |
qwen2.5:3b |
Good at structured JSON output |
llama3.2:3b |
Solid all-rounder |
Model files are not included in this repository. You download them with Ollama or llama.cpp as shown below.
git clone https://github.com/YOUR_USERNAME/citizendesk.git
cd citizendesk
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate
pip install -r requirements.txtcp .env.example .env # Windows: copy .env.example .envOpen .env and set TAVILY_API_KEY. Never commit this file.
-
Install Ollama from ollama.com, then check it:
ollama --version
-
(Windows, if your C: drive is low on space) Store models on another drive before pulling. Then fully quit Ollama from the system tray, and open a new terminal:
mkdir E:\OllamaModels setx OLLAMA_MODELS "E:\OllamaModels" -
Start the server and pull a model:
ollama serve # keep this window open ollama pull gemma4:e2b # in a second terminal (or gemma3:4b / qwen2.5:3b) ollama list # confirm it downloaded
-
Quick speed check:
ollama run gemma4:e2b --verbose
Use this if you prefer llama.cpp or want to run GGUF models from Hugging Face. llama.cpp provides an OpenAI-compatible server that the app talks to.
-
Install llama.cpp (pick one):
winget install llama.cpp # Windows brew install llama.cpp # macOS / Linux
Or download a pre-built binary from the releases page, or build from source:
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build --config Release -j -
Start the server. The
-hfflag downloads a model directly from Hugging Face (format:<user>/<model>[:quant]). Start with a small model on 8 GB RAM:llama-server -hf ggml-org/gemma-3-1b-it-GGUF --port 8080 -c 2048
To use a GGUF file you already downloaded:
llama-server -m path/to/model.gguf --port 8080 -c 2048
-
In
.env, point the app at it:LLM_BACKEND=llamacpp LLAMACPP_BASE_URL=http://localhost:8080/v1
# API with an interactive docs page
uvicorn app.api:app --reload
# then open http://127.0.0.1:8000/docs
# or the command-line demo
python demo.py| Variable | Default | Description |
|---|---|---|
TAVILY_API_KEY |
none | Web search key (required for research) |
LLM_BACKEND |
ollama |
ollama or llamacpp |
MODEL_NAME |
gemma4:e2b |
Model to use with Ollama |
OLLAMA_BASE_URL |
http://localhost:11434 |
Ollama server address |
LLAMACPP_BASE_URL |
http://localhost:8080/v1 |
llama.cpp server address |
OLLAMA_MODELS |
system default | Where Ollama stores model files |
Speed tuning (in app/config.py): NUM_CTX (context size, lower uses less RAM), KEEP_ALIVE (keeps the model loaded between calls), and the token limits for the JSON and writer models.
| Endpoint | Purpose |
|---|---|
POST /generate-complaint |
Run the agent: ranked contacts and a draft letter |
POST /feedback |
Report what happened (worked, no answer, wrong number, wrong department) |
GET /history |
Past complaints and outcomes |
GET /health |
API and model server status |
citizendesk/
βββ app/
β βββ config.py settings and limits
| βββ feedback.py take full info. if missing
β βββ models.py JSON model and writer model
β βββ prompts.py all prompt templates
β βββ state.py shared graph state
β βββ routers.py conditional-edge decisions
β βββ graph.py builds and compiles the LangGraph
β βββ memory.py SQLite memory
β βββ api.py FastAPI app
β βββ nodes/ intake, authority, researcher, verifier, writer, reviewer, feedback, save
β βββ tools/ search, extract, contacts, files
βββ data/ regions.json, seed_channels.json
βββ outputs/ generated letters and saved results
βββ tests/
βββ demo.py
βββ requirements.txt
βββ README.md
- The model never invents a contact. Contacts come from pages, via code, with a source and date.
- Fixed flow, small model. The graph decides the next step. The model does narrow jobs only.
- Show the confidence. Every recommendation says how sure the agent is and why.
- Treat failure as data. Dead numbers and redirects are stored and used in the next search.
- Stay private. Personal details are processed locally.
- The agent cannot confirm that a phone number is currently active. It ranks by evidence, and your feedback improves the ranking over time.
- Community knowledge is thin in many places. Some platforms (such as Facebook groups and X) can't be searched for free, so coverage varies by country.
- A small local model is weaker than a large cloud model, especially for Urdu and other low-resource languages. Check drafts before sending.
- Drafted letters are a starting point, not legal advice.
ollama is not recognized
Close the terminal and open a new one so it picks up the updated PATH. If it still fails, find ollama.exe (usually under %LOCALAPPDATA%\Programs\Ollama) and add that folder to your PATH.
The model downloads to C: even after setting OLLAMA_MODELS
The background server started before the variable existed. Quit Ollama from the system tray, open a new terminal, confirm echo $env:OLLAMA_MODELS shows your path, then run ollama serve from the new terminal.
Responses are very slow or the PC freezes
The model is probably larger than your free RAM, so Windows is swapping to disk. Close other apps, use a smaller model (gemma4:e2b, llama3.2:1b), keep NUM_CTX at 2048, and check ollama ps.
Research returns nothing
Check that TAVILY_API_KEY is set in .env. The app falls back to DuckDuckGo when Tavily fails, but that source is unofficial and may be rate-limited.
Ideas, bug reports, and verified region data are welcome. Open an issue first to discuss a larger change.
Released under the MIT License.
Ollama, llama.cpp, LangGraph, Tavily, and FastAPI
AR-CODE
If this project helps you, consider giving it a β