Skip to content

PythonicVarun/llm-circuit-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”Œ Circuit Lab - LLM Γ— Wokwi πŸ€–

A purely-browser playground 🌐 that lets any OpenAI-compatible LLM 🧠 generate complete Wokwi simulation projects πŸ› οΈ (diagram.json, firmware/source, supporting files) from natural-language prompts πŸ’¬, and runs them live in an embedded Wokwi simulator ⚑.

The LLM is fully user-supplied πŸ§‘β€πŸ’»: you provide a base URL, API key πŸ”‘, and model id - works with OpenAI, OpenRouter, Groq, Ollama, vLLM, LM Studio, Together, DeepInfra, Fireworks, and anything else that speaks /chat/completions πŸ—£οΈ.

πŸš€ Run

It's a static site - no build step πŸ™ƒ.

git clone https://github.com/PythonicVarun/llm-circuit-builder.git
cd llm-circuit-builder
python3 -m http.server 8000
# open http://localhost:8000

Or with any static server (npx serve ., caddy file-server, etc.) πŸ’».

⚠️ Open over http://localhost (not file://), otherwise the Wokwi iframe can't postMessage back πŸ›‘.

βš™οΈ How it works

  1. The Wokwi iframe πŸ–ΌοΈ (wokwi.com/experimental/embed) posts a MessagePort πŸšͺ to the parent on load.
  2. We wrap that port in WokwiClient πŸ“¦ (the protocol from wokwi/wokwi-embed-example).
  3. The LLM 🧠 is instructed to reply with a fenced ```wokwi-project JSON block 🧱:
    {
      "explanation": "…",
      "files": { "diagram.json": "…", "sketch.ino": "…" },
      "start":  { "firmware": "sketch.ino", "elf": "sketch.ino" }
    }
  4. Each file is uploaded via file:upload πŸ“€, then sim:start 🎬 kicks off the simulation.
  5. Serial output is streamed back into the on-page monitor πŸ“Ί.
  6. Every generated file is kept in an on-page file explorer πŸ—‚οΈ with nested-folder support (so the LLM is free to organise output into src/, lib/, etc.). One click downloads the whole project as a .zip πŸ“¦, or you can save any single file.

πŸ› οΈ Configure the LLM

Click Settings βš™οΈ in the top right. Fields:

Field Example
πŸ”— API base URL https://api.openai.com/v1
πŸ”‘ API key sk-…
πŸ€– Model ID gpt-4o-mini

Presets are included for OpenAI, OpenRouter, Groq, and Ollama πŸŽ›οΈ. Values are stored in localStorage only πŸ”’ - nothing leaves your browser except the chat-completion calls themselves πŸ›‘οΈ.

πŸ“ Files

  • πŸ“„ index.html - layout
  • 🎨 styles.css - phosphor-on-slate UI
  • 🧠 app.js - orchestrator (LLM ↔ Wokwi ↔ DOM)
  • πŸ€– llm.js - OpenAI-compatible streaming client + system prompt
  • πŸ—œοΈ zip.js - zero-dep STORE-method ZIP builder + path-to-tree grouping
  • πŸ”Œ wokwi-client.js, message-port-transport.js, base64.js - Wokwi embed protocol (MIT, CodeMagic LTD)

πŸ™ Credits

Wokwi embed protocol from https://github.com/wokwi/wokwi-embed-example (MIT, © 2025 CodeMagic LTD) ✨.

πŸ“œ License

This project is licensed under the MIT License. βš–οΈ

About

A browser playground to generate and run live Wokwi circuit simulations using any OpenAI-compatible LLM 🧠⚑️

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors