From f0a444ca465743dbe60d9dd8168c5e7646b9023b Mon Sep 17 00:00:00 2001 From: Hamza Ayed Date: Wed, 30 Sep 2026 09:16:51 +0300 Subject: [PATCH] Set Gemma 4 E2B as default and document Windows app --- SovereignAI-Starter/README.md | 22 ++++++++++++++-------- SovereignAI-Starter/push.sh | 26 ++++++++++++++++++++++++++ SovereignAI-Starter/start-api.ps1 | 3 ++- 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 SovereignAI-Starter/push.sh diff --git a/SovereignAI-Starter/README.md b/SovereignAI-Starter/README.md index 03cb6ac..3bd5011 100644 --- a/SovereignAI-Starter/README.md +++ b/SovereignAI-Starter/README.md @@ -1,6 +1,6 @@ # SovereignAI Starter -مشروع تعليمي لبناء مساعد ذكاء اصطناعي محلي قابل للتوسع. النموذج الافتراضي `qwen2.5:1.5b-instruct-q4_K_M` (نحو 986 ميغابايت)، ونموذج `gemma4:e2b` (نحو 7.16 غيغابايت) مثبت للتجربة والمقارنة. +مشروع تعليمي لبناء مساعد ذكاء اصطناعي محلي قابل للتوسع. النموذج الافتراضي الحالي `gemma4:e2b` ويعمل عبر Ollama محليًا. يمكن اختيار نموذج آخر بواسطة متغير البيئة `LOCAL_MODEL`. ## مكونات النسخة الأولى - FastAPI كواجهة HTTP محلية. @@ -20,27 +20,27 @@ py -m venv .venv python -m pip install -r requirements.txt ``` -4. (اختياري على جهاز جديد فقط) شغّل Ollama واسحب النموذج: +4. (اختياري على جهاز جديد فقط) شغّل Ollama واسحب Gemma 4 E2B: ```powershell -ollama pull qwen2.5:1.5b-instruct-q4_K_M +ollama pull gemma4:e2b ``` -الخادم الحالي مضبوط افتراضيًا على Ollama المحلي واسم النموذج أعلاه. لتغييرهما عرّف المتغيرات في نافذة PowerShell نفسها: +الخادم مضبوط افتراضيًا على Ollama المحلي وGemma 4 E2B. لتغيير عنوان Ollama أو اختيار نموذج آخر، عرّف المتغيرات في نافذة PowerShell نفسها: ```powershell $env:LOCAL_LLM_BASE_URL = "http://127.0.0.1:11434/v1" -$env:LOCAL_MODEL = "qwen2.5:1.5b-instruct-q4_K_M" +$env:LOCAL_MODEL = "gemma4:e2b" ``` -لتشغيل API على Gemma 4 بدل النموذج الافتراضي في نافذة PowerShell الحالية: +يمكن تثبيت اختيار Gemma صراحةً في الجلسة قبل تشغيل `start-api.ps1` (وهو النموذج الافتراضي للسكربت): ```powershell $env:LOCAL_MODEL = "gemma4:e2b" .\start-api.ps1 ``` -يمكن أيضًا اختيار النموذج لكل طلب من `POST /v1/chat/completions` بإرسال `model`، أو من `POST /v1/agent/run` بإرسال `model` مع `task`. يبقى النموذج الافتراضي Qwen ما لم تغيّره من البيئة. على جهاز الاختبار، Gemma 4 E2B اشتغلت محليًا على CPU، لكنها استخدمت قرابة 3.5 غيغابايت من الذاكرة أثناء التحميل؛ قد تختلف السرعة حسب الجهاز. +يمكن أيضًا اختيار النموذج لكل طلب من `POST /v1/chat/completions` بإرسال `model`، أو من `POST /v1/agent/run` بإرسال `model` مع `task`. على جهاز الاختبار، Gemma 4 E2B اشتغلت محليًا على CPU؛ وقد تختلف السرعة واستهلاك الذاكرة حسب الجهاز. راجع رخصة النموذج المختار وشروطه الحالية قبل الاستخدام التجاري. تنزيل النموذج يحتاج اتصال إنترنت ومساحة تخزين. @@ -63,7 +63,13 @@ python -m uvicorn app.main:app --reload --host 127.0.0.1 --port 8000 ## واجهة Flutter -يوجد تطبيق Flutter متعدد المنصات في `flutter_app`، ويبدأ كواجهة محادثة ويب عربية متصلة بهذا الـ API. راجع `flutter_app/README.md` للتشغيل. عنوان الاتصال الافتراضي `http://127.0.0.1:8000`؛ التطبيق يسمح بتغييره من الإعدادات. +يوجد تطبيق Flutter متعدد المنصات في `flutter_app`، ويبدأ كواجهة محادثة عربية متصلة بهذا الـ API. عنوان الاتصال الافتراضي `http://127.0.0.1:8000`؛ التطبيق يسمح بتغييره من الإعدادات ويعرض اسم النموذج النشط من الـ API. + +### تطبيق Windows + +- لتشغيل النسخة المكتبية، شغّل `start-api.ps1` أولًا، ثم افتح `flutter_app/build/windows/x64/runner/Release/flutter_app.exe` بعد بنائه. +- لإنشاء نسخة Release، نفّذ `flutter build windows --release` من داخل `flutter_app`. +- التطبيق المكتبي واجهة أمامية؛ يحتاج Ollama وFastAPI شغّالين على الجهاز. النموذج لا يُضمّن داخل ملف التطبيق التنفيذي، ويظل نسخ الصوت للنص عبر Groq Whisper عند استخدام الميكروفون. ### المحادثات والصوت diff --git a/SovereignAI-Starter/push.sh b/SovereignAI-Starter/push.sh new file mode 100644 index 0000000..8de6e9b --- /dev/null +++ b/SovereignAI-Starter/push.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +cd "$repo_dir" + +expected_origin="https://git.intaleqapp.com/Hamza/sovereign_ai.git" +actual_origin="$(git remote get-url origin)" +if [[ "$actual_origin" != "$expected_origin" ]]; then + printf 'Unexpected origin: %s\nExpected: %s\n' "$actual_origin" "$expected_origin" >&2 + exit 1 +fi + +branch="$(git branch --show-current)" +if [[ -z "$branch" ]]; then + echo 'Cannot push from a detached HEAD.' >&2 + exit 1 +fi + +git add -A +if ! git diff --cached --quiet; then + message="${*:-Update SovereignAI project}" + git commit -m "$message" +fi + +git push --set-upstream origin "$branch" diff --git a/SovereignAI-Starter/start-api.ps1 b/SovereignAI-Starter/start-api.ps1 index 824b43d..f5a2d16 100644 --- a/SovereignAI-Starter/start-api.ps1 +++ b/SovereignAI-Starter/start-api.ps1 @@ -14,8 +14,9 @@ $ollama = Invoke-RestMethod -Uri 'http://127.0.0.1:11434/api/tags' -TimeoutSec 5 $model = if ($env:LOCAL_MODEL) { $env:LOCAL_MODEL } else { - 'qwen2.5:1.5b-instruct-q4_K_M' + 'gemma4:e2b' } +Write-Host "Local model: $model" if (-not ($ollama.models.name -contains $model)) { throw "Ollama is running, but model '$model' is missing. Run: ollama pull $model" }