--- name: ollama-local description: تشغيل LLMs محلياً مجاناً 100% عبر Ollama. خصوصية كاملة (بيانات KCPC السرية لا تخرج للسحاب)، offline، بدون tokens. يدعم 100+ موديل (Llama, Qwen, Mistral, DeepSeek, Phi, Gemma). مثالي لـ: معالجة وثائق سرية، embeddings محلية، RAG على بيانات حساسة. التكلفة: $0. license: MIT ---
Ollama Local LLMs
تشغيل LLMs محلياً بخصوصية كاملة.
Status
- ✅ Ollama 0.23.2 installed
- ✅ Service running on
http://localhost:11434 - Models installed: check via
ollama list(last seen: qwen2.5:3b). Do not assume a specific model name in scripts; query/api/tagsfirst.
Use Cases for د. وائل
| الاستخدام | لماذا محلي؟ | |---|---| | 📄 وثائق KCPC السرية | لا ترسل للسحاب | | 📋 عقود سرية | خصوصية مطلقة | | 🔐 بيانات شخصية | offline تماماً | | 💰 معالجة كميات ضخمة | بدون cost per token | | ⚡ توليد embeddings | للـ RAG محلياً | | 🌐 بدون إنترنت | يعمل في أي مكان |
Commands
bash
List installed models
ollama listPull a model
ollama pull mistral:7b
ollama pull qwen2.5:14b
ollama pull aya:8b # multilingual including Arabic
ollama pull deepseek-r1:14b # reasoningRun interactively
ollama run qwen3:1.7b "ترجم: Method statement"API (compatible with OpenAI)
curl http://localhost:11434/v1/chat/completions -d '{
"model": "qwen3:1.7b",
"messages": [{"role":"user","content":"hello"}]
}'As OpenAI-compatible (python)
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
Recommended Models
| Model | Size | RAM | Speed | Best For | |---|---|---|---|---| | qwen3:1.7b ✅ | 1.4GB | 2GB | ⚡⚡⚡⚡⚡ | Quick, multi-lang (current) | | qwen2.5:7b | 4.5GB | 6GB | ⚡⚡⚡⚡ | General + Arabic | | qwen2.5:14b | 9GB | 12GB | ⚡⚡⚡ | Quality reasoning | | aya:8b | 4.8GB | 6GB | ⚡⚡⚡⚡ | Multilingual specialist | | mistral:7b | 4.1GB | 6GB | ⚡⚡⚡⚡ | Fast general | | deepseek-r1:14b | 8.5GB | 12GB | ⚡⚡ | Reasoning + math | | llama3.3:70b | 40GB | 64GB | ⚡ | Frontier quality (GPD only) |
Integration with Translate Skill
bash
Add Ollama as another tier in translate
Edit translate.py to add tx_local() function using Ollama
Integration with Paperclip
Use Ollama for embedding sensitive documents locally:
python
import requests
def local_embed(text):
r = requests.post("http://localhost:11434/api/embeddings",
json={"model": "mxbai-embed-large", "prompt": text})
return r.json()["embedding"]
Persist Service
bash
Already started — service persists across sessions
ps aux | grep ollama
Log: /data/.openclaw/logs/ollama.log
Cron Health Check & Auto-Restart
Used by the scheduled "Ollama health check — auto-restart if needed" cron. Handle internally; do not relay to user unless asked.
/api/tags returning 200 is NOT sufficient — inference can hang while the API still responds. Always do a real generate probe.
1. API liveness:
curl -sS --max-time 5 http://localhost:11434/api/tags -o /dev/null -w "HTTP:%{http_code}\n"
2. Pick an installed model from /api/tags (do not hardcode names).
3. Inference probe (30s timeout):
curl -sS --max-time 30 -X POST http://localhost:11434/api/generate -H 'Content-Type: application/json' -d '{"model":"<installed>","prompt":"reply OK","stream":false,"options":{"num_predict":5}}'
4. Restart if either probe fails (timeout / non-2xx / curl exit≠0). No systemd; runs as standalone ollama serve:
bash
pid=$(pgrep -f "ollama serve")
[ -n "$pid" ] && kill -TERM $pid
for i in 1 2 3 4 5 6 7 8; do sleep 1; pgrep -f "ollama serve" >/dev/null || break; done
pgrep -f "ollama serve" >/dev/null && kill -KILL $pid && sleep 1
nohup /data/.local/bin/ollama serve >> /data/.openclaw/logs/ollama.log 2>&1 < /dev/null &
disown 2>/dev/null
sleep 3
Then re-run both probes. First post-restart generate may take ~10–15s (cold load) — use --max-time 60.