This is the Oneline Version(code base in dev-online branch), you can just visit the link and don't have to deploy it!
This project is inspired by ai-artifacts, aiming to implement a similar product in a simpler way to gain a deeper understanding of the technology.
With just 130 lines of code, we've created a product similar to Artifacts. This project is intended for quickly learning technical principles and has not considered many edge cases, so there may be numerous bugs.
The code relies on Gradio and E2B. Thanks to the open-source community for making technology exploration so simple.
pip install -r requirements.txt
# Set environment variables E2B_API_KEY and ANTHROPIC_API_KEY before using
export E2B_API_KEY=your_key
export ANTHROPIC_API_KEY=your_key
# run the code
python3 main.py
- Gradio Interface: Provides a user-friendly chat interface and display area for generated web content.
- Anthropic's Claude AI: Generates Next.js code based on user prompts.
- E2B Sandbox: Creates a real-time Next.js environment to render the generated code.
- User inputs a description or request for a web component.
- The input is sent to Claude AI through the Anthropic API.
- Claude generates TSX code based on the prompt.
- The code is sent to the E2B sandbox running a Next.js environment.
- The sandbox renders the code and returns a URL.
- The rendered content is displayed in an iframe within the Gradio interface.
E2B is a very user-friendly Code Interpreter tool that also supports custom Docker image uploads, making it extremely powerful.
Gradio is very easy to get started with, allowing programmers who are not proficient in React or other front-end technology stacks to quickly develop a UI and validate products.