Showing posts with label gemma. Show all posts
Showing posts with label gemma. Show all posts

Sunday

ADK Smart Home Multi-Agent System



📢 Excited to share my latest creation: the ADK Smart Home Multi-Agent System! 🏠💡


In a world where smart homes are becoming increasingly ubiquitous, the real challenge is creating seamlessly integrated, intelligent, and proactive systems. I've been developing a comprehensive solution that brings together real-time IoT data, weather intelligence, and AI-powered insights, all of which are controllable and viewable through Google Home.


The ADK Smart Home Multi-Agent System is a sophisticated multi-agent microservice application designed for environmental monitoring and smart home automation. It's built around:


🏡 Real-time IoT Monitoring: Leveraging Arduino-based sensors, it captures precise indoor temperature and humidity data.


☁️ City-Wide Weather Intelligence: Integrates with external APIs (like OpenWeatherMap) to provide current outdoor temperature, humidity, and weather descriptions.


🤖 Multi-Agent Architecture (ADK): Built with the Agent Development Kit, the system features distinct iot-agent and weather-agent services, ensuring modularity, scalability, and robust communication.


🧠 AI-Powered Insights (Ollama): Integrates a local Large Language Model (Ollama with Gemma 3:1B) for intelligent data processing and potentially more nuanced interactions.


🗣️ Seamless Google Home Integration:


Account Linking & Device Discovery: Smooth onboarding to connect your smart home with Google Home.


Voice Control (QUERY): Get instant updates on indoor/outdoor conditions just by asking Google Assistant (e.g., "Hey Google, what's the indoor temperature?").


Automatic Updates (REPORT_STATE): Configured to proactively push device state changes to Google Home, ensuring your app dashboard always shows the latest data without manual refresh!


This system addresses real-world problems, from enhancing home comfort and energy efficiency to enabling precise microclimate monitoring tailored to specific needs.


It’s a testament to how modular, agent-based design can create intelligent, responsive, and highly scalable IoT solutions.


Tech Stack Highlights: Docker Compose, FastAPI, Python, PostgreSQL, Redis, httpx, Ollama, and of course, deep integration with Google Home APIs.


Feel free to check out the project on GitHub [https://github.com/dhirajpatra/google-home-adk-iot-real-time-analysis] and see how it all comes together!


Thursday

OLLama and Gemma3 Tiny Test On CPU

Have you ever tested the tiny LLM Gemma3:1B with OLLama on your laptop or system that lacks a GPU?









You can build a fairly powerful GenAI application; however, it can be a little slow due to CPU processing. 

Steps:

  1. Download and install ollama if not already there in your system: 
    1. go to https://ollama.com/download and get the installation command
    2. Check the ollama running by `ollama --version`
  2. Now pull the Gemma LLM: 
    1. Go to https://ollama.com/library/gemma3
    2. Run: `ollama pull  gemma3:1b`
  3. Run Ollama server with LLM if not already running
    1. Check the list: `ollama list`
    2. Run: `ollama serve`
  4. Install the pip lib 
    1. Run: `pip install ollama`
    2. Run: `pip install "jupyter-ai[ollama]`
  5. To stop the ollama server
    1. Run: `ps aux | grep ollama`
    2. Run: `kill <PID>`
    3. Run: `sudo systemctl stop ollama`
That all. Now got to your jupyter notebook. If not running run by command: `jupyter lab` or `jupyter notebook`


Now it is your turn to configure, tuneing and develop many different application from RAG to Agentic AI. You can find out more code in my Github repos and also get the quick start guide here in blog. Thank you.

Monday

Local Gemma3 as VSCode Code Generation Extension

To use the #Gemma3:1B model directly in #VSCode as a #codeassistant, you'll need to set up a local inference server or use an API that integrates with VS Code.


Here's a step-by-step guide:


Option 1: Run Gemma Locally & Integrate with VS Code

1. Install Required Dependencies

Ensure you have Python (≥3.9) and `pip` installed. Then, install the necessary packages:

```bash

pip install transformers torch sentencepiece

```


2. Load Gemma 3:1B in a Python Script

Create a Python script (`gemma_inference.py`) to load the model:

```python

from transformers import AutoTokenizer, AutoModelForCausalLM


model_id = "google/gemma-3-1b-it" # or "google/gemma-3-7b-it" if you have more resources

tokenizer = AutoTokenizer.from_pretrained(model_id)

model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")


def generate_code(prompt):

  inputs = tokenizer(prompt, return_tensors="pt").to("cuda")

  outputs = model.generate(**inputs, max_length=200)

  return tokenizer.decode(outputs[0], skip_special_tokens=True)


# Test

print(generate_code("Write a Python function to reverse a string."))

```


3. Set Up a Local API (Optional)

If you want to interact with the model via HTTP (e.g., for VS Code extensions), use `FastAPI`:

```bash

pip install fastapi uvicorn

```

Create `api.py`:

```python

from fastapi import FastAPI

from gemma_inference import generate_code


app = FastAPI()


@app.post("/generate")

async def generate(prompt: str):

  return {"response": generate_code(prompt)}

```

Run it:

```bash

uvicorn api:app --reload

```


4. Integrate with VS Code

- Option A: Use the REST Client extension to send requests to `http://localhost:8000/generate`.

- Option B: Create a VS Code extension that calls the API (requires JavaScript/TypeScript knowledge).


---


Option 2: Use an Existing VS Code Extension

If you don’t want to run Gemma locally:

1. Use Google’s #Vertex AI (if Gemma is available there) and call its API.

2. Use Ollama :

  ```bash

  ollama pull gemma3:1b 

  ollama run gemma3:1b

  ```

3. Use Continue.dev (VS Code extension that supports local #LLMs).


---


Option 3: Use Hugging Face Inference API (Cloud)

If you prefer not to run the model locally:

1. Get a Hugging Face API key.

2. Use the `huggingface_hub` package:

  ```python

  from huggingface_hub import InferenceClient

  client = InferenceClient(token="YOUR_HF_TOKEN")

  output = client.text_generation("Write Python code for a linked list.")

  print(output)

  ```


---


Performance Notes

- Gemma 3:1B is small enough to run on a consumer GPU (e.g., RTX 3060+) or CPU but is slow.

- For VS Code autocomplete, consider building a custom extension that queries the model on-the-fly.


House Based Manufacturing Micro Clustering

                                 image generated by meta ai House-based manufacturing micro-clustering in China refers to the hyper-local, v...