Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Agentic AI Python Playwright LLM

๐Ÿค– Subaru AI โ€” Autonomous E-Commerce Agent

An Agentic AI system that autonomously browses, searches, compares, and purchases products on e-commerce websites using natural language commands.

What is Agentic AI? โ€ข Features โ€ข Architecture โ€ข Quick Start โ€ข Usage โ€ข Demo


๐Ÿง  What is Agentic AI?

Agentic AI represents the next evolution in artificial intelligenceโ€”systems that don't just respond to queries but autonomously take actions to achieve goals. Unlike traditional chatbots that only provide information, Agentic AI systems:

Traditional AI Agentic AI (This Project)
Answers questions Executes tasks autonomously
Requires step-by-step instructions Decomposes goals into sub-tasks
Single-turn interactions Multi-step planning & execution
Passive responses Active browser manipulation
No environmental interaction Real-time DOM interaction & verification

๐ŸŽฏ This Project Demonstrates:

User: "Find me a gaming laptop with RTX 4060, i7 processor under 1 lakh on Amazon and add to wishlist"

The Agent Autonomously:

  1. ๐Ÿ” Reasons about the request using LLM (Gemini/Groq)
  2. ๐Ÿ“‹ Plans a multi-step execution strategy
  3. ๐ŸŒ Navigates to Amazon.in
  4. ๐Ÿ”Ž Searches with optimized queries ("gaming laptop RTX 4060 i7")
  5. ๐Ÿ’ฐ Filters products by price range
  6. ๐Ÿ“Š Analyzes product listings using NLU
  7. โœ… Verifies specs match requirements (RTX 4060, i7, under โ‚น1L)
  8. โค๏ธ Adds to wishlist with confirmation
  9. ๐Ÿ“ Reports results back to user

โœจ Key Features

๐Ÿค– Autonomous Agent Capabilities

  • Natural Language Understanding: Understands complex, multi-part shopping requests
  • Dynamic Intent Extraction: Extracts product type, specs, budget, and actions from any query
  • Intelligent Site Selection: Automatically chooses best e-commerce site for product category
  • Adaptive Execution: Handles popups, CAPTCHAs, and dynamic page content
  • Self-Verification: Confirms actions were successful before proceeding

๐Ÿงช Robust & Production-Ready

  • Typo Tolerance: Handles "gameing lapotp" โ†’ "gaming laptop"
  • Multi-Site Support: Amazon, Flipkart, Myntra, Ajio, TheSouledStore, Bewakoof
  • Persistent Login: Maintains authenticated sessions across runs
  • Adversarial Testing: 100% pass rate on 29+ edge case tests
  • Fallback Reasoning: Works even without LLM (rule-based fallback)

๐Ÿ”ง Technical Highlights

Component Technology
Browser Automation Playwright (async, anti-detection)
LLM Integration Google Gemini (primary), Groq Llama (fallback)
NLU/NER Custom intent parser + DistilBERT extraction
UI Streamlit (real-time status updates)
API FastAPI (REST endpoints)
Storage SQLite (session logs, task history)
Testing Pytest (unit + integration + adversarial)

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         USER INTERFACE                               โ”‚
โ”‚                    (Streamlit UI / CLI / API)                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    INTELLIGENT REASONING ENGINE                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚
โ”‚  โ”‚   Intent    โ”‚  โ”‚   Dynamic   โ”‚  โ”‚    Site     โ”‚                  โ”‚
โ”‚  โ”‚  Analysis   โ”‚โ”€โ”€โ”‚   Product   โ”‚โ”€โ”€โ”‚  Selection  โ”‚                  โ”‚
โ”‚  โ”‚   (LLM)     โ”‚  โ”‚ Extraction  โ”‚  โ”‚   Logic     โ”‚                  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   ENHANCED UNIFIED ORCHESTRATOR                      โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚
โ”‚  โ”‚    Task     โ”‚  โ”‚   Action    โ”‚  โ”‚   State     โ”‚                  โ”‚
โ”‚  โ”‚  Planning   โ”‚โ”€โ”€โ”‚  Executor   โ”‚โ”€โ”€โ”‚  Manager    โ”‚                  โ”‚
โ”‚  โ”‚             โ”‚  โ”‚             โ”‚  โ”‚             โ”‚                  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      PLAYWRIGHT RUNNER                               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚
โ”‚  โ”‚ Persistent  โ”‚  โ”‚    Anti-    โ”‚  โ”‚   Action    โ”‚                  โ”‚
โ”‚  โ”‚   Context   โ”‚โ”€โ”€โ”‚  Detection  โ”‚โ”€โ”€โ”‚ Verificationโ”‚                  โ”‚
โ”‚  โ”‚   (Login)   โ”‚  โ”‚   Scripts   โ”‚  โ”‚             โ”‚                  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                    โ”‚
                                    โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    E-COMMERCE WEBSITES                               โ”‚
โ”‚     Amazon.in  โ”‚  Flipkart  โ”‚  Myntra  โ”‚  Ajio  โ”‚  + More           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Agent Decision Flow

graph TD
    A[User Query] --> B{Intent Analysis}
    B --> C[Extract Product Type]
    B --> D[Extract Specs/Budget]
    B --> E[Detect Actions]
    
    C --> F{Known Category?}
    F -->|Yes| G[Use Category Rules]
    F -->|No| H[Dynamic NLU Extraction]
    
    G --> I[Select Best Sites]
    H --> I
    
    I --> J[Generate Search Query]
    J --> K[Execute Browser Actions]
    
    K --> L{Action Success?}
    L -->|Yes| M[Continue to Next Step]
    L -->|No| N[Retry with Fallback]
    
    M --> O{More Actions?}
    O -->|Yes| K
    O -->|No| P[Return Results]
    
    N --> L
Loading

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+ (for Playwright)
  • API Key: Gemini or Groq

Installation

# Clone the repository
git clone https://github.com/yourusername/subaru-ai.git
cd subaru-ai

# Create virtual environment
python -m venv .venv
.venv\Scripts\activate  # Windows
# source .venv/bin/activate  # Linux/Mac

# Install dependencies
pip install -r requirements.txt

# Install Playwright browsers
playwright install chromium

Configuration

Create a .env file in the project root:

# LLM API Keys (at least one required)
GEMINI_API_KEY=your_gemini_api_key_here
GROQ_API_KEY=your_groq_api_key_here

# Optional: Site Credentials for authenticated actions
AMAZON_EMAIL=your_email@example.com
AMAZON_PASSWORD=your_password

Run the Agent

# Start Streamlit UI
streamlit run src/ui/app.py

# Or run via CLI
python run_unified_agent.py "Find gaming laptop under 80000 on Amazon"

๐Ÿ“– Usage

Natural Language Commands

The agent understands a wide variety of natural language commands:

# Simple product search
"Find me wireless headphones under 5000"

# Multi-constraint search
"Search for Samsung phone with 8GB RAM under 25000 on Flipkart"

# Action commands
"Add the first iPhone 15 to my Amazon wishlist"

# Complex queries with typos (handled automatically!)
"gameing lapotp with rtx 4060 i7 16gb under 1 lakh"

# Comparison queries
"Compare iPhone 15 vs Samsung S24"

# Fashion searches
"Anime hoodie for winter on Souled Store"

Supported Actions

Action Example Command
Search "Find RTX 4070 laptops"
Filter by Price "Under 50000", "Below 1 lakh"
Filter by Rating "4+ stars", "Highly rated"
Add to Cart "Add to cart", "Buy this"
Add to Wishlist "Save for later", "Add to wishlist"
Login "Login to Amazon" (uses saved credentials)
Compare "Compare products"

Supported Sites

Site Categories
Amazon.in Electronics, Everything
Flipkart.com Electronics, Fashion
Myntra.com Fashion
Ajio.com Fashion
TheSouledStore.com Anime/Fandom Merchandise
Bewakoof.com Casual Wear
Croma.com Electronics, Appliances

๐ŸŽฌ Demo

Example: Gaming Laptop Search

Input:

Find me a gaming laptop with RTX 4060 and i7 processor under 1 lakh on Amazon

Agent Execution:

๐Ÿ” Analyzing intent...
   โ””โ”€ Product: gaming laptop
   โ””โ”€ Specs: RTX 4060, i7
   โ””โ”€ Budget: โ‚น100,000
   โ””โ”€ Site: amazon.in

๐ŸŒ Opening Amazon.in...
   โ””โ”€ โœ… Page loaded

๐Ÿ”Ž Searching: "gaming laptop RTX 4060 i7"...
   โ””โ”€ โœ… Search results loaded

๐Ÿ’ฐ Applying price filter: โ‚น70,000 - โ‚น100,000...
   โ””โ”€ โœ… Filter applied

๐Ÿ“Š Analyzing 24 products...
   โ””โ”€ Filtering by specs: RTX 4060, i7
   โ””โ”€ Found 8 matching products

๐Ÿ“‹ Top Results:
   1. ASUS TUF Gaming F15 - โ‚น94,990 โญ 4.3
   2. Acer Nitro V Gaming - โ‚น89,990 โญ 4.1
   3. HP Victus Gaming - โ‚น87,990 โญ 4.2

โœ… Task completed successfully!

๐Ÿงช Testing

# Run all tests
pytest

# Run adversarial tests (edge cases)
pytest tests/test_adversarial.py -v

# Run with coverage
pytest --cov=src --cov-report=html

Adversarial Test Coverage

The agent is tested against 29+ adversarial scenarios:

  • โœ… Typo handling ("headpones" โ†’ "headphones")
  • โœ… Paraphrase robustness ("Show me" vs "Find" vs "Search for")
  • โœ… Budget parsing ("50k", "1 lakh", "โ‚น50000")
  • โœ… Site extraction from context
  • โœ… Non-product query detection
  • โœ… Substring matching bugs ("watching" โ‰  "watch")

๐Ÿ“ Project Structure

subaru-ai/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ enhanced_unified_orchestrator.py  # Main agent orchestrator
โ”‚   โ”‚   โ”œโ”€โ”€ intelligent_reasoning.py          # NLU & intent analysis
โ”‚   โ”‚   โ””โ”€โ”€ commands.py                       # Action definitions
โ”‚   โ”œโ”€โ”€ executors/
โ”‚   โ”‚   โ”œโ”€โ”€ playwright_runner.py              # Browser automation
โ”‚   โ”‚   โ”œโ”€โ”€ dynamic_action_executor.py        # Action execution
โ”‚   โ”‚   โ””โ”€โ”€ chromeprofile.py                  # Persistent login manager
โ”‚   โ”œโ”€โ”€ nlu/
โ”‚   โ”‚   โ”œโ”€โ”€ enhanced_llm_client.py            # Gemini/Groq clients
โ”‚   โ”‚   โ””โ”€โ”€ intent_schema.json                # Intent validation schema
โ”‚   โ”œโ”€โ”€ perception/
โ”‚   โ”‚   โ””โ”€โ”€ ner.py                            # Named entity recognition
โ”‚   โ”œโ”€โ”€ ui/
โ”‚   โ”‚   โ””โ”€โ”€ app.py                            # Streamlit interface
โ”‚   โ””โ”€โ”€ api/
โ”‚       โ””โ”€โ”€ server.py                         # FastAPI backend
โ”œโ”€โ”€ configs/
โ”‚   โ””โ”€โ”€ sites/                                # Site-specific selectors
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_adversarial.py                   # Edge case tests
โ”‚   โ””โ”€โ”€ integration/                          # Integration tests
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐Ÿ”ฎ Roadmap

  • Vision Integration: Screenshot analysis for dynamic sites
  • Voice Commands: Speech-to-text input
  • Multi-Agent: Parallel site searching
  • Price Tracking: Historical price monitoring
  • Smart Recommendations: ML-based product suggestions

๐Ÿค Contributing

Contributions are welcome! Please read our contributing guidelines and submit PRs.


๐Ÿ“„ License

MIT License - see LICENSE for details.


Built with โค๏ธ for the future of Agentic AI

โญ Star this repo if you find it useful!

About

Agentic AI E-Commerce Browser Agent - Autonomous shopping with natural language

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages