-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
193 lines (176 loc) · 10.1 KB
/
Copy pathindex.html
File metadata and controls
193 lines (176 loc) · 10.1 KB
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
188
189
190
191
192
193
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Circuit Lab · LLM-driven Wokwi simulations</title>
<link rel="stylesheet" href="styles.css" />
<link rel="icon"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%230a0e14'/%3E%3Cpath d='M4 16h6l2-6 4 12 2-6h10' stroke='%2334d399' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E" />
</head>
<body>
<header class="topbar">
<div class="brand">
<svg viewBox="0 0 32 32" width="22" height="22" aria-hidden="true">
<path d="M2 16h6l2-7 4 14 2-7h14" stroke="currentColor" stroke-width="2.2" fill="none"
stroke-linecap="round" stroke-linejoin="round" />
</svg>
<span class="brand-name">Circuit Lab</span>
<span class="brand-tag">/ llm × wokwi</span>
</div>
<div class="topbar-actions">
<span id="llm-status" class="pill pill-warn" title="LLM not configured">LLM: not configured</span>
<span id="sim-status" class="pill" title="Simulator status">sim: idle</span>
<button id="settings-btn" class="ghost-btn" title="Configure LLM">
<svg viewBox="0 0 24 24" width="16" height="16">
<path
d="M12 8a4 4 0 100 8 4 4 0 000-8zm7 2.8l2-1.6-2-3.4-2.4.8a8 8 0 00-2-1.2L14 2.8h-4l-.6 2.6a8 8 0 00-2 1.2L5 5.8l-2 3.4 2 1.6a8 8 0 000 2.4l-2 1.6 2 3.4 2.4-.8a8 8 0 002 1.2l.6 2.6h4l.6-2.6a8 8 0 002-1.2l2.4.8 2-3.4-2-1.6a8 8 0 000-2.4z"
stroke="currentColor" stroke-width="1.4" fill="none" />
</svg>
Settings
</button>
</div>
</header>
<main class="layout">
<!-- LEFT: chat -->
<section class="panel chat-panel">
<div class="panel-header" style="gap: 0.25rem; flex-direction: column;">
<h2>Describe a circuit</h2>
<div class="session-bar">
<div class="session-combo">
<input id="session-input" class="session-input" type="text" placeholder="Search sessions…" autocomplete="off" spellcheck="false" />
<div id="session-list" class="session-list hidden" role="listbox"></div>
</div>
<button id="session-new" class="ghost-btn small" title="New session">+</button>
<button id="session-delete" class="ghost-btn small" title="Delete this session">×</button>
<span class="ver-divider"></span>
<button id="ver-prev" class="ghost-btn small" title="Previous version" disabled>‹</button>
<span id="ver-label" class="ver-label" title="Version (up to 5 kept)">v0/0</span>
<button id="ver-next" class="ghost-btn small" title="Next version" disabled>›</button>
</div>
</div>
<div id="messages" class="messages">
<div class="msg msg-system">
<p>Tell me what you want to build. The LLM writes <code>diagram.json</code> + firmware, then we run
it in Wokwi on the right.</p>
<div class="examples">
<button class="example">Blink an LED on Arduino UNO pin 13</button>
<button class="example">ESP32 MicroPython - print uptime over serial</button>
<button class="example">Pi Pico + HC-SR04, log distance every 500 ms</button>
<button class="example">Arduino UNO + potentiometer reading on A0 to serial</button>
<button class="example">Knight Rider - 6 LEDs sweeping on UNO pins 2–7</button>
</div>
</div>
</div>
<form id="composer" class="composer">
<textarea id="prompt" rows="3"
placeholder="Describe your circuit, or ask the LLM to change the current one…"></textarea>
<div class="composer-row">
<span class="hint">⌘/Ctrl + Enter to send</span>
<button id="send-btn" type="submit">Generate ›</button>
</div>
</form>
</section>
<div id="split-cols" class="splitter splitter-h" role="separator" aria-orientation="vertical" title="Drag to resize"></div>
<!-- RIGHT: simulator -->
<section class="panel sim-panel">
<div class="panel-header">
<h2>Simulator</h2>
<div class="sim-actions">
<button id="btn-start" class="ghost-btn small" disabled>start</button>
<button id="btn-pause" class="ghost-btn small" disabled>pause</button>
<button id="btn-stop" class="ghost-btn small" disabled title="Halt and reset to t=0">stop</button>
<button id="btn-restart" class="ghost-btn small" disabled>restart</button>
<button id="btn-files" class="ghost-btn small" disabled>files…</button>
</div>
</div>
<div class="iframe-wrap">
<iframe id="wokwi-embed" src="https://wokwi.com/experimental/embed" allow="serial; usb"
title="Wokwi simulator"></iframe>
</div>
<div id="split-rows" class="splitter splitter-v" role="separator" aria-orientation="horizontal" title="Drag to resize"></div>
<div class="serial">
<div class="serial-header">
<span class="dot"></span>
<span>serial monitor</span>
<button id="serial-clear" class="ghost-btn small">clear</button>
</div>
<pre id="serial-out" class="serial-out" tabindex="0"></pre>
</div>
</section>
</main>
<!-- LLM SETTINGS MODAL -->
<div id="settings-modal" class="modal hidden" role="dialog" aria-modal="true" aria-labelledby="settings-title">
<div class="modal-card">
<div class="modal-head">
<h3 id="settings-title">LLM configuration</h3>
<button class="ghost-btn small" id="settings-close">close</button>
</div>
<p class="modal-sub">Any OpenAI-compatible Chat Completions endpoint. Keys live in your browser only
(localStorage).</p>
<label>
<span>API base URL</span>
<input id="cfg-base" type="text" placeholder="https://api.openai.com/v1" autocomplete="off" />
</label>
<label>
<span>API key</span>
<input id="cfg-key" type="password" placeholder="sk-…" autocomplete="off" />
</label>
<label>
<span>Model ID</span>
<input id="cfg-model" type="text" placeholder="gpt-4o-mini" autocomplete="off" />
</label>
<details class="presets">
<summary>presets</summary>
<div class="preset-grid">
<button class="preset" data-base="https://api.openai.com/v1" data-model="gpt-4o-mini">OpenAI ·
gpt-4o-mini</button>
<button class="preset" data-base="https://api.openai.com/v1" data-model="gpt-4o">OpenAI ·
gpt-4o</button>
<button class="preset" data-base="https://openrouter.ai/api/v1"
data-model="anthropic/claude-3.5-sonnet">OpenRouter · claude-3.5-sonnet</button>
<button class="preset" data-base="https://openrouter.ai/api/v1"
data-model="google/gemini-2.0-flash-exp:free">OpenRouter · gemini-2.0-flash</button>
<button class="preset" data-base="https://api.groq.com/openai/v1"
data-model="llama-3.3-70b-versatile">Groq · llama-3.3-70b</button>
<button class="preset" data-base="http://localhost:11434/v1" data-model="qwen2.5-coder:7b">Ollama ·
qwen2.5-coder</button>
</div>
</details>
<div class="modal-foot">
<button id="cfg-clear" class="ghost-btn small">forget</button>
<button id="cfg-save" class="primary-btn">Save</button>
</div>
</div>
</div>
<!-- FILES DRAWER -->
<div id="files-modal" class="modal hidden" role="dialog" aria-modal="true">
<div class="modal-card wide">
<div class="modal-head">
<h3>Project files <span id="files-count" class="files-count"></span></h3>
<div class="files-head-actions">
<button id="files-download" class="primary-btn small" title="Download all files as a zip">
<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true">
<path d="M8 1v9m0 0l-3-3m3 3l3-3M2 12v2h12v-2" stroke="currentColor" stroke-width="1.6"
fill="none" stroke-linecap="round" stroke-linejoin="round" />
</svg>
Download .zip
</button>
<button class="ghost-btn small" id="files-close">close</button>
</div>
</div>
<div class="files-layout">
<div id="files-tree" class="files-tree"></div>
<div class="files-pane">
<div class="files-pane-head">
<span id="files-active-path" class="files-active-path">No file selected</span>
<button id="files-download-one" class="ghost-btn small" disabled>download file</button>
</div>
<pre id="files-view" class="files-view"><code>Select a file from the tree</code></pre>
</div>
</div>
</div>
</div>
<script type="module" src="app.js"></script>
</body>
</html>