Here's an API reference document that explains the features of the hypertext_heaven.py file and how to use them:
The Hypertext Heaven module provides a Heaven class that automates the process of creating webpages using various AI agents. It generates HTML, CSS, and JavaScript code, and can even create images based on the webpage content.
heaven = Heaven()Creates a new Heaven instance, initializing several AI agents for different tasks.
Creates a complete webpage based on a given idea.
-
Parameters:
idea(str): The concept or idea for the webpage.previous_page(str, optional): HTML content of a previous version to iterate upon.
-
Usage:
heaven = Heaven() heaven.create_webpage("A portfolio website for a digital artist")
These methods are used internally by create_webpage() but can be called separately if needed:
Generates a detailed outline for the webpage.
Creates the HTML structure based on the outline.
Generates CSS for the webpage.
Creates JavaScript for the webpage's functionality.
Combines HTML, CSS, and JavaScript into a single, valid HTML file.
Saves the final webpage, generating images for <img> tags and CSS background images.
The Heaven class uses several AI agents for different tasks:
agent_405b: Uses "Meta: Llama 3.1 405B Instruct" model for generating outlines.agent_sonnet: Uses "Anthropic: Claude 3.5 Sonnet" model for HTML and CSS generation.agent_opus: Uses "Anthropic: Claude 3 Opus" model for JavaScript generation and final combination.agent_gpt4o: Uses "gpt-4o-mini-or" model for generating image descriptions.agent_flux: Uses "flux-dev" model for generating images.
The _save_page() method automatically generates images for:
- All
<img>tags in the HTML. - All background images specified in the CSS.
It uses agent_gpt4o to create descriptions and agent_flux to generate the actual images.
The script can be run from the command line:
python hypertext_heaven.py <idea> [previous_page]
<idea>: Required. The concept for the webpage.[previous_page]: Optional. Path to an HTML file of a previous version to iterate upon.
from hypertext_heaven import Heaven
heaven = Heaven()
heaven.create_webpage("A responsive landing page for a tech startup")This will generate a complete HTML file with embedded CSS and JavaScript, along with any necessary images, saved in the current directory.
- The generated webpage is designed to run locally without external dependencies.
- Image generation may fail silently if there are any errors.
- The script requires an active internet connection to communicate with the AI models.
@Deertick can use this API to automate the creation of webpages, including content, structure, styling, functionality, and even images, all driven by AI.