DEV Community

Cover image for Buy or Bye — An AI Purchase Reality Check for My Impulse-Buying Friend
Meghana
Meghana

Posted on

Buy or Bye — An AI Purchase Reality Check for My Impulse-Buying Friend

Why Does Open Innovation Matter?

Using the open-weight Gemma 3:1b model through Ollama allows Buy or Bye to run its AI explanation layer locally instead of relying on a closed hosted LLM API.

This makes the AI workflow local, controllable, and transparent.

🎥 Demo

Demo video: https://www.loom.com/share/149be4d701334eef9021cf69c96f4ce6

🔗 Project

GitHub Repository: https://github.com/Meghana-2124/buy-or-bye

How the Decision Works

Buy or Bye evaluates:

  • Budget — Is the product within the user's budget?
  • Need — How strongly is the product needed?
  • Usage — How often will it be used?
  • Existing Product — Is something similar already owned?
  • Impulse — How impulsive is the purchase?
  • Cheaper Alternative — Is there a cheaper option that meets the need?

Decision Logic

Python uses deterministic rules to generate one of three verdicts:

BUY  → Purchase factors are generally positive
WAIT → There are reasons to reconsider
BYE  → The purchase does not make sense based on the inputs
Enter fullscreen mode Exit fullscreen mode

The decision is calculated before involving the AI model.

Why Gemma Is Used

Gemma is the explanation layer, not the decision-maker.

Python → Decides
Gemma  → Explains
Enter fullscreen mode Exit fullscreen mode

Python provides the fixed verdict and purchase factors, while Gemma turns them into a short natural-language explanation.

Why SerpApi Is Used

SerpApi provides current web information about the product.

Python  → Personal purchase decision
SerpApi → Current web information
Gemma   → Explanation
Enter fullscreen mode Exit fullscreen mode

The search results provide additional context but do not change the personal verdict.

Example

Product: Headphones
Price: ₹30,000
Budget: ₹50,000
Usage: 15 times/month
Need: 4/5
Similar product: No
Impulse: 2/5
Cheaper alternative: No

Verdict: BUY
Enter fullscreen mode Exit fullscreen mode

Changing the inputs can produce WAIT or BYE.

Technology Stack

  • Python
  • Streamlit
  • Gemma 3:1b
  • Ollama
  • SerpApi
  • Requests
  • python-dotenv

Project Structure

buy-or-bye/
├── app.py
├── README.md
├── LICENSE
├── requirements.txt
├── .gitignore
└── screenshots/
    ├── main-interface.png
    ├── purchase-reality-check.png
    ├── web-information.png
    └── gemmas-verdict.png
Enter fullscreen mode Exit fullscreen mode

Running the Project Locally

Prerequisites

  • Python
  • Ollama
  • Gemma 3:1b
  • SerpApi API key

Install Dependencies

pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Install Gemma

ollama pull gemma3:1b
Enter fullscreen mode Exit fullscreen mode

Configure SerpApi

Create .env:

SERPAPI_KEY=your_serpapi_api_key
Enter fullscreen mode Exit fullscreen mode

Run the Application

streamlit run app.py
Enter fullscreen mode Exit fullscreen mode

Design Philosophy

Each component has a clear role:

  • Python — decision logic
  • Gemma — natural-language explanation
  • SerpApi — current web context

This keeps the system simple and transparent.

Limitations

Buy or Bye is a decision-support tool, not financial advice.

The verdict depends on the user's provided information and does not account for their complete financial situation.

Future Improvements

  • Price tracking
  • Product comparison
  • Better alternative discovery
  • Purchase history
  • Personalized spending insights
  • Additional open-weight models

Prize Categories

Gemma

Uses Gemma 3:1b as the core open-weight AI explanation layer through Ollama.

SerpApi

Uses SerpApi for current web information about products.

License

This project is released under the MIT License.

Final Thought

"Is this product worth buying?"

Maybe the better question is:

"Is this purchase worth it for me?"
Yes.

Top comments (0)