{"id":27019160,"url":"https://github.com/fullstackcodingguy/jabi","last_synced_at":"2025-04-04T17:19:21.956Z","repository":{"id":285212313,"uuid":"957407325","full_name":"FullstackCodingGuy/JABI","owner":"FullstackCodingGuy","description":"Just a bot idea - personal task management assistant.","archived":false,"fork":false,"pushed_at":"2025-03-30T10:22:35.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T10:28:03.380Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FullstackCodingGuy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-30T09:45:24.000Z","updated_at":"2025-03-30T10:22:39.000Z","dependencies_parsed_at":"2025-03-30T10:38:07.666Z","dependency_job_id":null,"html_url":"https://github.com/FullstackCodingGuy/JABI","commit_stats":null,"previous_names":["fullstackcodingguy/justabot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FJABI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FJABI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FJABI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FJABI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FullstackCodingGuy","download_url":"https://codeload.github.com/FullstackCodingGuy/JABI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217216,"owners_count":20903009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-04T17:19:21.408Z","updated_at":"2025-04-04T17:19:21.942Z","avatar_url":"https://github.com/FullstackCodingGuy.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Just A Bot Idea\n\u003e Personal task management assistant.\n\n\nRunning gemma model locally,\nFirst ensure your ollama instance is running\n```\nollama pull gemma:2b\n```\n\n\nTo build an **AI-powered personal assistant** for mobile, follow these steps:  \n\n---\n\n## **🔹 1. Define the Core Features**  \n✅ **Conversational AI** (text \u0026 voice-based interactions)  \n✅ **Multi-Modal Support** (text, voice, images, documents)  \n✅ **Task Automation** (reminders, scheduling, note-taking)  \n✅ **Integration with APIs** (weather, news, calendar, smart home)  \n✅ **Offline Mode** (on-device inference for privacy \u0026 speed)  \n\n---\n\n## **🔹 2. Choose the Tech Stack**  \n**🔸 Frontend (Mobile App UI)**  \n- **Flutter** (Dart) → Cross-platform (iOS \u0026 Android)  \n- **React Native** (JS/TS) → Web \u0026 Mobile  \n- **Native Android (Kotlin) / iOS (Swift)** → Best performance  \n\n**🔸 Backend (AI Processing \u0026 APIs)**  \n- **Gemma 2B / Mistral 7B** → LLM for fast on-device inference  \n- **Whisper** → Speech-to-Text (voice interactions)  \n- **TTS (Text-to-Speech)** → For voice output  \n- **FastAPI / Flask** → For cloud-based AI APIs  \n\n**🔸 Database \u0026 Storage**  \n- **SQLite / Room (Mobile)** → Local storage  \n- **ChromaDB / Pinecone** → AI memory for conversations  \n- **Firebase / Supabase** → Cloud sync  \n\n---\n\n## **🔹 3. Build the AI Assistant Core**  \n\n### **🛠️ Step 1: Set Up the AI Model (On-Device LLM)**\nUse **Gemma 2B** for fast local processing.\n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer\nimport torch\n\n# Load Gemma 2B model for on-device inference\nmodel_name = \"google/gemma-2b\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map=\"auto\")\n\ndef chat_with_ai(prompt):\n    inputs = tokenizer(prompt, return_tensors=\"pt\").to(\"cuda\")\n    output = model.generate(**inputs, max_length=200)\n    return tokenizer.decode(output[0], skip_special_tokens=True)\n\nprint(chat_with_ai(\"How can I improve my productivity?\"))\n```\n\n---\n\n### **🛠️ Step 2: Add Speech-to-Text (STT)**\nUse **Whisper** to convert voice to text.\n\n```python\nimport whisper\n\nmodel = whisper.load_model(\"small\")\nresult = model.transcribe(\"audio.mp3\")\nprint(result[\"text\"])\n```\n\n---\n\n### **🛠️ Step 3: Text-to-Speech (TTS)**\nUse **Google TTS / Coqui TTS** for voice responses.\n\n```python\nfrom gtts import gTTS\nimport os\n\ntext = \"Hello! How can I assist you today?\"\ntts = gTTS(text)\ntts.save(\"response.mp3\")\nos.system(\"mpg321 response.mp3\")\n```\n\n---\n\n### **🛠️ Step 4: Connect to Mobile App (Flutter / React Native)**\nUse **HTTP APIs / WebSockets** to integrate the AI backend with your mobile app.\n\nExample API (FastAPI):\n\n```python\nfrom fastapi import FastAPI\napp = FastAPI()\n\n@app.get(\"/chat\")\nasync def chat(prompt: str):\n    response = chat_with_ai(prompt)\n    return {\"response\": response}\n\n```\n\n---\n\n### **Integrating Gemma for Intent Recognition in a Personal Assistant**  \n\nTo use **Gemma** for **intent recognition** in your personal assistant, follow these steps:  \n\n---\n\n## **🔹 1. Approach to Intent Recognition**\n### ✅ **Steps**:\n1️⃣ **User Input** → The assistant receives a **text command**  \n2️⃣ **Gemma Processes the Input** → The LLM **analyzes intent**  \n3️⃣ **Intent Classification** → Matches the query to a **predefined action**  \n4️⃣ **Execute Action** → Calls the function or API  \n5️⃣ **Generate Response** → LLM confirms the action  \n\n---\n\n## **🔹 2. Running Gemma Locally for Intent Recognition**\nSince **Gemma is an open-source model**, you can run it locally using **Ollama** or **Hugging Face Transformers**.\n\n### **🛠️ Step 1: Install Ollama (For Local Inference)**\n```sh\n# Install Ollama (Mac/Linux)\ncurl -fsSL https://ollama.com/install.sh | sh\n\n# Install Gemma model\nollama pull gemma:2b\n```\n\n### **🛠️ Step 2: Process User Queries with Intent Detection**\n```typescript\nimport fetch from \"node-fetch\";\n\n// Function to call Gemma LLM\nasync function callGemma(prompt: string): Promise\u003cstring\u003e {\n  const response = await fetch(\"http://localhost:11434/api/generate\", {\n    method: \"POST\",\n    headers: { \"Content-Type\": \"application/json\" },\n    body: JSON.stringify({ model: \"gemma:2b\", prompt })\n  });\n\n  const data = await response.json();\n  return data.response.trim();\n}\n\n// Define Intent Handlers\nconst intentHandlers: { [key: string]: Function } = {\n  \"set_alarm\": (time: string) =\u003e `Alarm set for ${time}.`,\n  \"send_email\": (recipient: string, subject: string) =\u003e\n    `Email sent to ${recipient} with subject: ${subject}.`,\n};\n\n// Function to recognize intent\nasync function processIntent(userQuery: string): Promise\u003cstring\u003e {\n  const prompt = `\n  Classify the intent of the following message into one of these intents: \n  - set_alarm\n  - send_email\n  - unknown\n\n  Message: \"${userQuery}\"\n  Response (JSON): \n  `;\n\n  const response = await callGemma(prompt);\n  console.log(\"LLM Response:\", response);\n\n  try {\n    const result = JSON.parse(response);\n    if (intentHandlers[result.intent]) {\n      return intentHandlers[result.intent](...(result.parameters || []));\n    }\n  } catch (e) {\n    console.error(\"Error parsing response:\", e);\n  }\n\n  return \"Sorry, I couldn't understand the request.\";\n}\n\n// Example Usage\nprocessIntent(\"Set an alarm for 6 AM\").then(console.log);\nprocessIntent(\"Send an email to john@example.com with subject Meeting\").then(console.log);\n```\n\n✅ **Runs fully locally using Gemma 2B**  \n✅ **Extracts intent \u0026 executes predefined functions**  \n\n---\n\n## **🔹 3. Fine-Tuning Gemma for Better Intent Recognition**\nFor **better accuracy**, train Gemma on **custom intent datasets**.\n\n### **🛠️ Steps to Fine-Tune with Hugging Face**\n1️⃣ **Prepare labeled dataset (text → intent mappings)**  \n2️⃣ **Use Hugging Face `transformers` to fine-tune Gemma**  \n3️⃣ **Deploy the fine-tuned model locally**  \n\n```python\nfrom transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, Trainer\n\n# Load Gemma model \u0026 tokenizer\nmodel_name = \"google/gemma-2b\"\ntokenizer = AutoTokenizer.from_pretrained(model_name)\nmodel = AutoModelForCausalLM.from_pretrained(model_name)\n\n# Example dataset (fine-tuning intent classification)\ndataset = [\n    {\"input\": \"Set an alarm for 7 AM\", \"intent\": \"set_alarm\"},\n    {\"input\": \"Remind me to call Alex\", \"intent\": \"set_reminder\"},\n    {\"input\": \"Send an email to John with subject Urgent\", \"intent\": \"send_email\"},\n]\n\n# Convert dataset into tokenized format\ndef tokenize_function(example):\n    return tokenizer(example[\"input\"], padding=\"max_length\", truncation=True)\n\n# Train model (if needed)\ntraining_args = TrainingArguments(output_dir=\"./results\", per_device_train_batch_size=4, num_train_epochs=3)\ntrainer = Trainer(model=model, args=training_args, train_dataset=dataset)\n\ntrainer.train()\n```\n\n✅ **Fine-tunes Gemma for intent classification**  \n✅ **Improves accuracy for specific use cases**  \n\n---\n\n## **🔹 4. Deploying in a Mobile App**\nTo integrate with a **mobile assistant (Flutter/React Native)**:\n- **Backend**: Run Gemma on **FastAPI/Node.js**  \n- **Frontend**: Send API requests for **intent recognition \u0026 action execution**  \n- **Voice Integration**: Use **Google TTS / Whisper for voice input/output**  \n\n\n\n\n-------------\n\n\n\n- https://www.linkedin.com/pulse/running-ai-models-locally-ollama-jerome-lecomte-kuwuf/\n- https://ollama.com/blog/openai-compatibility\n- https://ollama.com/library/codellama\n- https://www.datacamp.com/tutorial/deepseek-r1-ollama\n- https://medium.com/@tubelwj/complete-guide-to-running-ollamas-large-language-model-llm-locally-part-1-97f936da4eb0\n- https://github.com/ollama/ollama-js","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullstackcodingguy%2Fjabi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffullstackcodingguy%2Fjabi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullstackcodingguy%2Fjabi/lists"}