File size: 6,556 Bytes
e4117ea
 
 
 
 
 
f0493ea
e4117ea
f0493ea
e4117ea
f0493ea
e4117ea
f0493ea
 
e4117ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0493ea
e4117ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0493ea
e4117ea
 
 
 
 
 
f0493ea
e4117ea
 
 
 
 
 
 
 
 
f0493ea
 
 
 
 
 
e4117ea
 
f0493ea
 
 
 
e4117ea
 
 
 
 
 
 
 
 
f0493ea
e4117ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0493ea
 
e4117ea
 
 
 
 
f0493ea
 
 
e4117ea
 
f0493ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4117ea
 
 
 
 
 
 
 
f0493ea
 
 
 
 
 
e4117ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ๐Ÿš€ VIBE CODER v2.0 MAX โ€” Official Google Colab Studio\n",
    "\n",
    "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/shawaz03/LLM/blob/main/vibe_coder_quickstart.ipynb)\n",
    "\n",
    "Run **Vibe Coder v2.0 MAX (7B)** on a **Free Google Colab T4 GPU** in 4-bit NF4 Quantization (5.2 GB VRAM, 0 memory errors).\n",
    "\n",
    "- **Hugging Face Model**: [`shawaz03/vibe-coder-7b-max`](https://huggingface.co/shawaz03/vibe-coder-7b-max)\n",
    "- **Specialization**: Autonomous Full-Stack React 19, Next.js 15, TypeScript, Tailwind CSS, Prisma, and Anti-AI Aesthetic Directives."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. Install Dependencies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install -q transformers torch accelerate bitsandbytes huggingface_hub"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. Load Model in 4-bit (Fast & Zero Memory Overhead)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TextStreamer\n",
    "\n",
    "MODEL_ID = \"shawaz03/vibe-coder-7b-max\"\n",
    "print(f\"๐Ÿš€ Loading {MODEL_ID} in 4-bit NF4...\")\n",
    "\n",
    "bnb_config = BitsAndBytesConfig(\n",
    "    load_in_4bit=True,\n",
    "    bnb_4bit_quant_type=\"nf4\",\n",
    "    bnb_4bit_use_double_quant=True,\n",
    "    bnb_4bit_compute_dtype=torch.float16,\n",
    ")\n",
    "\n",
    "tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)\n",
    "model = AutoModelForCausalLM.from_pretrained(\n",
    "    MODEL_ID,\n",
    "    quantization_config=bnb_config,\n",
    "    device_map=\"auto\",\n",
    "    trust_remote_code=True,\n",
    ")\n",
    "model.eval()\n",
    "streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)\n",
    "\n",
    "print(\"\\nโœ… VIBE CODER IS READY!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. Vibe Coder Engine Definition"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "VIBE_CODER_SYSTEM_PROMPT = \"\"\"You are Vibe Coder, a world-class principal full-stack software engineer and UI/UX designer.\n",
    "ENGINEERING & CODING DIRECTIVES:\n",
    "1. COMPLETE IMPLEMENTATIONS: Never output '// TODO', '/* implement later */', or incomplete stubs. Every component, hook, and route must be fully written.\n",
    "2. NO ARTIFACT STRINGS: Never output template tags, variant numbers (e.g. 'Build Variant #...'), or internal directive texts.\n",
    "3. FULL STATE & INTERACTION: Include real mock data arrays, working toggle logic, and complete TypeScript types.\n",
    "4. MODERN DESIGN SYSTEM: Use Tailwind CSS with dark neutral palettes (bg-neutral-900, border-neutral-800), clean accents (cyan, emerald, violet), and Lucide React icons.\n",
    "5. CLEAN OUTPUT: Output standard, clean TypeScript/React code with 'use client' when state is used.\"\"\"\n",
    "\n",
    "def ask_vibe_coder(prompt_text, temperature=0.2, max_tokens=1500):\n",
    "    if not prompt_text.strip():\n",
    "        print(\"โš ๏ธ Please enter a prompt in the box below.\")\n",
    "        return\n",
    "\n",
    "    messages = [\n",
    "        {\"role\": \"system\", \"content\": VIBE_CODER_SYSTEM_PROMPT},\n",
    "        {\"role\": \"user\", \"content\": prompt_text}\n",
    "    ]\n",
    "    \n",
    "    formatted_prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)\n",
    "    inputs = tokenizer(formatted_prompt, return_tensors=\"pt\").to(\"cuda\")\n",
    "    \n",
    "    print(\"=\" * 75)\n",
    "    print(f\"๐Ÿ’ฌ USER PROMPT: {prompt_text}\")\n",
    "    print(\"=\" * 75 + \"\\n\")\n",
    "    \n",
    "    with torch.no_grad():\n",
    "        model.generate(\n",
    "            **inputs,\n",
    "            streamer=streamer,\n",
    "            max_new_tokens=max_tokens,\n",
    "            temperature=temperature,\n",
    "            top_p=0.95,\n",
    "            repetition_penalty=1.05,\n",
    "            do_sample=True,\n",
    "            eos_token_id=tokenizer.eos_token_id,\n",
    "            pad_token_id=tokenizer.pad_token_id,\n",
    "        )\n",
    "    print(\"\\n\" + \"=\" * 75)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 4. ๐ŸŽฎ Dynamic Prompt Studio (Interactive Form Box)\n",
    "Type your custom prompt into the box below and click the **Play (Run)** button:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "cellView": "form"
   },
   "outputs": [],
   "source": [
    "# @title ๐Ÿš€ Vibe Coder Interactive Code Generator { vertical-output: true }\n",
    "# @markdown Enter your custom prompt and configure generation settings:\n",
    "\n",
    "prompt = \"Build an interactive pricing matrix in React with Tailwind CSS, supporting monthly/annual billing toggle, 5 feature bullet checkmarks, and popular badge with zero placeholders.\"  # @param {type:\"string\"}\n",
    "temperature = 0.2  # @param {type:\"slider\", min:0.05, max:1.0, step:0.05}\n",
    "max_tokens = 1500  # @param {type:\"slider\", min:256, max:3072, step:128}\n",
    "\n",
    "ask_vibe_coder(prompt, temperature=temperature, max_tokens=max_tokens)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 5. ๐Ÿ’ฌ Continuous Live Chat Loop\n",
    "Run this cell to chat and prompt continuously in real-time:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "while True:\n",
    "    user_query = input(\"\\n๐Ÿ‘‰ Type any prompt (or 'exit' to quit): \")\n",
    "    if not user_query.strip() or user_query.lower() in [\"exit\", \"quit\"]:\n",
    "        print(\"Session stopped.\")\n",
    "        break\n",
    "    ask_vibe_coder(user_query, temperature=0.2)"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "gpuType": "T4",
   "provenance": []
  },
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}