From 5c02b3e097f6d70a45b1fdb04bebc97feaaccf56 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Fri, 24 Oct 2025 06:18:19 +0000
Subject: [PATCH] feat: Create AI Website Builder
This commit introduces a new web application that allows users to generate websites from text prompts using multiple LLMs.
The application features:
- A user interface for entering a prompt and an API key.
- Dynamic creation of result cards for each LLM.
- Streaming API calls to the specified endpoints.
- A "live coding" effect as the HTML is generated.
- A live preview of the generated website in an iframe.
- Progress indicators.
- Fullscreen previews.
- Options to copy or download the generated code.
The application is built with HTML, CSS, and JavaScript. The API key is not hardcoded in the source code for security reasons. Instead, the user is prompted to enter their own API key.
---
index.html | 78 ++++++++
script.js | 574 +++++++++++++++++++++++++++++++++++++++++++++++++++++
style.css | 314 +++++++++++++++++++++++++++++
3 files changed, 966 insertions(+)
create mode 100644 index.html
create mode 100644 script.js
create mode 100644 style.css
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..de09098
--- /dev/null
+++ b/index.html
@@ -0,0 +1,78 @@
+
+
+
+
+
+ AI Website Builder
+
+
+
+
+
AI Website Builder
+
Enter a description of the website you want to create, and watch AI models build it for you in real-time.
+
+
+
+
+
+ Generate Websites
+
+
+
+
+
+ GLM-4.6
+ qwen3-max
+ qwen3-coder
+ tbao
+ kimi-k2
+
+
+
Initializing...
+
+
+
+
+
+
Your generated websites will appear here
+
Get started by entering a prompt above.
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/script.js b/script.js
new file mode 100644
index 0000000..4c80a99
--- /dev/null
+++ b/script.js
@@ -0,0 +1,574 @@
+// Configuration
+const API_CONFIG = {
+ baseUrl: 'https://apis.iflow.cn/v1',
+ models: [
+ {
+ name: 'GLM-4.6',
+ model: 'glm-4.6',
+ baseUrl: 'https://apis.iflow.cn/v1',
+ },
+ {
+ name: 'qwen3-max',
+ model: 'qwen3-max',
+ baseUrl: 'https://apis.iflow.cn/v1',
+ },
+ {
+ name: 'qwen3-coder',
+ model: 'qwen3-coder-plus',
+ baseUrl: 'https://apis.iflow.cn/v1',
+ },
+ {
+ name: 'tbao',
+ model: 'tstars2.0',
+ baseUrl: 'https://apis.iflow.cn/v1',
+ },
+ {
+ name: 'kimi-k2',
+ model: 'kimi-k2-0905',
+ baseUrl: 'https://apis.iflow.cn/v1',
+ },
+ ]
+};
+
+// State management
+let currentResults = [];
+let isGenerating = false;
+let currentCodeForModal = '';
+let activeTypingAnimations = {};
+
+// Initialize
+document.addEventListener('DOMContentLoaded', () => {
+ initializeEventListeners();
+ checkEmptyState();
+ console.log('AI Website Builder initialized');
+});
+
+function initializeEventListeners() {
+ // Enter key shortcut
+ document.getElementById('promptInput').addEventListener('keydown', (e) => {
+ if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
+ generateWebsites();
+ }
+ });
+
+ document.getElementById('generateBtn').addEventListener('click', generateWebsites);
+
+ // Close modal on outside click
+ document.getElementById('codeModal').addEventListener('click', (e) => {
+ if (e.target.id === 'codeModal') {
+ closeModal();
+ }
+ });
+
+ // Close fullscreen on ESC key
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') {
+ closeFullscreen();
+ }
+ });
+}
+
+async function generateWebsites() {
+ const prompt = document.getElementById('promptInput').value.trim();
+
+ if (!prompt) {
+ showToast('Please enter a website description', 'error');
+ return;
+ }
+
+ if (isGenerating) {
+ showToast('Generation already in progress', 'warning');
+ return;
+ }
+
+ console.log('Starting generation with prompt:', prompt);
+
+ isGenerating = true;
+ const generateBtn = document.getElementById('generateBtn');
+ const resultsContainer = document.getElementById('resultsContainer');
+ const emptyState = document.getElementById('emptyState');
+ const progressSection = document.getElementById('progressSection');
+
+ // Update UI states
+ generateBtn.classList.add('loading');
+ generateBtn.disabled = true;
+ generateBtn.querySelector('.btn-text').textContent = 'Generating...';
+ emptyState.style.display = 'none';
+ progressSection.style.display = 'block';
+
+ // Clear previous results
+ resultsContainer.innerHTML = '';
+ currentResults = [];
+
+ // Clear any active typing animations
+ Object.values(activeTypingAnimations).forEach(animation => clearInterval(animation));
+ activeTypingAnimations = {};
+
+ // Animate LLM badges
+ const badges = document.querySelectorAll('.llm-badge');
+ badges.forEach(badge => badge.classList.remove('active'));
+
+ try {
+ const models = API_CONFIG.models;
+ const totalModels = models.length;
+
+ for (let i = 0; i < models.length; i++) {
+ const model = models[i];
+
+ console.log(`Processing model ${i + 1}/${totalModels}: ${model.name}`);
+
+ // Update progress
+ updateProgress((i / totalModels) * 100, `Generating with ${model.name}...`);
+
+ // Activate current badge
+ if (badges[i]) badges[i].classList.add('active');
+
+ // Create result card with loading state
+ const cardId = `result-${i}`;
+ const card = createResultCard({
+ id: cardId,
+ llm: model.name,
+ status: 'loading',
+ html: ''
+ });
+ resultsContainer.appendChild(card);
+
+ try {
+ // Generate HTML with the model and show live coding
+ await generateWithModelLive(model, prompt, cardId);
+
+ } catch (error) {
+ console.error(`Error with ${model.name}:`, error);
+ updateResultCard(cardId, {
+ llm: model.name,
+ status: 'error',
+ error: error.message || 'Unknown error occurred'
+ });
+ }
+
+ // Deactivate badge
+ if (badges[i]) badges[i].classList.remove('active');
+ }
+
+ updateProgress(100, 'Generation complete!');
+ showToast('All websites generated successfully!', 'success');
+
+ } catch (error) {
+ console.error('Generation error:', error);
+ showToast('Failed to generate websites: ' + error.message, 'error');
+ } finally {
+ // Reset UI states
+ isGenerating = false;
+ generateBtn.classList.remove('loading');
+ generateBtn.disabled = false;
+ generateBtn.querySelector('.btn-text').textContent = 'Generate Websites';
+
+ setTimeout(() => {
+ progressSection.style.display = 'none';
+ }, 2000);
+ }
+}
+
+async function generateWithModelLive(model, prompt, cardId) {
+ const apiKey = document.getElementById('apiKeyInput').value.trim();
+ if (!apiKey) {
+ showToast('Please enter your API key', 'error');
+ throw new Error('API Key is required.');
+ }
+ const systemPrompt = `You are an expert web developer. Generate complete, valid HTML code for the requested website.
+Include inline CSS styles within a
+
+
+ Generated Website
+ ${prompt}
+
+
Feature 1
+
Modern and responsive design
+
+
+
Feature 2
+
Clean and professional layout
+
+
+
Feature 3
+
Customizable content
+
+ Note: API connection failed. This is a fallback template.
+ Model: ${model.name}
+
+