Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -127,10 +127,68 @@ coordinator = CodeAgent(
|
|
| 127 |
|
| 128 |
# --- Gradio UI ---
|
| 129 |
with gr.Blocks() as demo:
|
| 130 |
-
gr.Markdown(
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
gr.Markdown("""
|
| 135 |
CodeAgent | openai/gpt-4.1-mini
|
| 136 |
├── ✅ Authorized imports: ['numpy']
|
|
|
|
| 127 |
|
| 128 |
# --- Gradio UI ---
|
| 129 |
with gr.Blocks() as demo:
|
| 130 |
+
gr.Markdown(
|
| 131 |
+
"""
|
| 132 |
+
# 🧠 Multi-Agent Thin-Film Stack Optimizer (10nm + 100nm RCWA)
|
| 133 |
+
|
| 134 |
+
This interactive demo showcases a **multi-agent AI system** that cooperatively solves an inverse optics problem using physics-based simulation.
|
| 135 |
+
Instead of relying on a single agent or a single simulator, the **Coordinator Agent** orchestrates two specialized agents, each tuned to simulate optical spectra for different layer thicknesses (10nm and 100nm), and uses a comparison tool to evaluate results.
|
| 136 |
+
|
| 137 |
+
---
|
| 138 |
+
|
| 139 |
+
### 🤖 Objective: Discover the correct layer **order** and **thickness**
|
| 140 |
+
|
| 141 |
+
Given only a target transmission spectrum, the multi-agent system must identify:
|
| 142 |
+
- The correct **material permutation** (from a fixed set), and
|
| 143 |
+
- The correct **thickness choice** (10nm or 100nm, uniformly applied)
|
| 144 |
+
|
| 145 |
+
**Constraints:**
|
| 146 |
+
- Materials: `Si`, `Si₃N₄`, `SiO₂`, `AlN` (used once each)
|
| 147 |
+
- Layer thickness options: `10nm` or `100nm`
|
| 148 |
+
- Terminate when `cosine_similarity > 0.999`
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
### 🧬 Agent Architecture Overview
|
| 153 |
+
|
| 154 |
+
- 🧠 **Coordinator Agent** (`CodeAgent | gpt-4.1-mini`):
|
| 155 |
+
Receives the target spectrum and is responsible for reasoning, selecting candidates, and delegating simulations to sub-agents.
|
| 156 |
+
|
| 157 |
+
- 🔧 **agent_10nm_simulator**:
|
| 158 |
+
Can simulate any material order using **10nm** thick layers via RCWA.
|
| 159 |
+
|
| 160 |
+
- 🔧 **agent_100nm_simulator**:
|
| 161 |
+
Can simulate any material order using **100nm** thick layers via RCWA.
|
| 162 |
+
|
| 163 |
+
- 📏 **cosine_similarity tool**:
|
| 164 |
+
Measures how close a simulated spectrum is to the target.
|
| 165 |
+
|
| 166 |
+
---
|
| 167 |
+
|
| 168 |
+
### 🔍 What’s Happening Under the Hood
|
| 169 |
+
|
| 170 |
+
1. A **random 4-layer stack** is selected from `Si`, `Si₃N₄`, `SiO₂`, `AlN`, and simulated (at 100nm) to serve as the **target spectrum**.
|
| 171 |
+
2. The **Coordinator Agent** is provided the target and access to two sub-agents:
|
| 172 |
+
- `agent_10nm_simulator` for 10nm stacks
|
| 173 |
+
- `agent_100nm_simulator` for 100nm stacks
|
| 174 |
+
3. It explores permutations + thickness combinations by:
|
| 175 |
+
- Calling a simulation agent
|
| 176 |
+
- Comparing simulated output with the target using `cosine_similarity`
|
| 177 |
+
- Continuing exploration until similarity exceeds threshold
|
| 178 |
+
4. The system **halts automatically** once the optimal stack is found, and reports:
|
| 179 |
+
- The matched material order
|
| 180 |
+
- Thickness value
|
| 181 |
+
- Number of permutations tried
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
### 📊 Visualization
|
| 186 |
+
|
| 187 |
+
> (Optional) Below: Transmission spectra for all permutations using 100nm layers
|
| 188 |
+
Observe how layer order significantly affects optical behavior.
|
| 189 |
+
"""
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
gr.Markdown("""
|
| 193 |
CodeAgent | openai/gpt-4.1-mini
|
| 194 |
├── ✅ Authorized imports: ['numpy']
|