ivoryos 0.1.9__py3-none-any.whl → 0.1.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ivoryos might be problematic. Click here for more details.

Files changed (37) hide show
  1. ivoryos/__init__.py +122 -99
  2. ivoryos/config.py +47 -47
  3. ivoryos/routes/auth/auth.py +100 -65
  4. ivoryos/routes/auth/templates/auth/login.html +25 -25
  5. ivoryos/routes/auth/templates/auth/signup.html +32 -32
  6. ivoryos/routes/control/control.py +400 -272
  7. ivoryos/routes/control/templates/control/controllers.html +75 -75
  8. ivoryos/routes/control/templates/control/controllers_home.html +50 -50
  9. ivoryos/routes/control/templates/control/controllers_new.html +89 -89
  10. ivoryos/routes/database/database.py +188 -114
  11. ivoryos/routes/database/templates/database/experiment_database.html +72 -72
  12. ivoryos/routes/design/design.py +543 -416
  13. ivoryos/routes/design/templates/design/experiment_builder.html +415 -415
  14. ivoryos/routes/design/templates/design/experiment_run.html +325 -325
  15. ivoryos/routes/main/main.py +42 -25
  16. ivoryos/routes/main/templates/main/help.html +141 -141
  17. ivoryos/routes/main/templates/main/home.html +68 -68
  18. ivoryos/static/.DS_Store +0 -0
  19. ivoryos/static/js/overlay.js +12 -12
  20. ivoryos/static/js/socket_handler.js +34 -34
  21. ivoryos/static/js/sortable_card.js +24 -24
  22. ivoryos/static/js/sortable_design.js +36 -36
  23. ivoryos/static/style.css +201 -201
  24. ivoryos/templates/base.html +143 -143
  25. ivoryos/utils/db_models.py +544 -518
  26. ivoryos/utils/form.py +328 -316
  27. ivoryos/utils/global_config.py +67 -67
  28. ivoryos/utils/llm_agent.py +183 -183
  29. ivoryos/utils/script_runner.py +166 -164
  30. ivoryos/utils/utils.py +437 -422
  31. ivoryos/version.py +1 -0
  32. {ivoryos-0.1.9.dist-info → ivoryos-0.1.12.dist-info}/LICENSE +21 -21
  33. {ivoryos-0.1.9.dist-info → ivoryos-0.1.12.dist-info}/METADATA +170 -169
  34. ivoryos-0.1.12.dist-info/RECORD +47 -0
  35. {ivoryos-0.1.9.dist-info → ivoryos-0.1.12.dist-info}/WHEEL +1 -1
  36. ivoryos-0.1.9.dist-info/RECORD +0 -45
  37. {ivoryos-0.1.9.dist-info → ivoryos-0.1.12.dist-info}/top_level.txt +0 -0
@@ -1,416 +1,416 @@
1
- {% extends 'base.html' %}
2
- {% block title %}IvoryOS | Design{% endblock %}
3
-
4
- {% block body %}
5
- {# <div id="overlay" class="overlay">Generating design, please wait...</div>#}
6
- <div id="overlay" class="overlay">
7
- <div>
8
- <h3 id="overlay-text">Generating design, please wait...</h3>
9
- <div class="spinner-border" role="status"></div>
10
- </div>
11
- </div>
12
- <div class="row">
13
- <div class="col-md-3 scroll-column" >
14
-
15
- {# select deck if this is online#}
16
- {% if off_line %}
17
- <form id="select-deck" method="POST" action="{{ url_for('design.import_pseudo') }}" enctype="multipart/form-data">
18
- <div class="input-group mb-3">
19
- {# <label for="pkl_name" class="form-label">Choose/Change deck:</label>#}
20
- <select class="form-select" name="pkl_name" id="pkl_name" required onchange="document.getElementById('select-deck').submit();">
21
- <option {{ '' if 'pseudo_deck' in session else 'selected' }} disabled hidden style="overflow-wrap: break-word;" name="pkl_name" id="pkl_name" value=""> -- choose deck --</option>
22
- {% for connection in history %}
23
- <option {{ 'selected' if session['pseudo_deck']==connection else '' }} style="overflow-wrap: break-word;" name="pkl_name" id="pkl_name" value="{{connection}}">{{connection.split('.')[0]}}</option>
24
- {% endfor %}
25
- </select>
26
- </div>
27
- </form>
28
- <hr>
29
- {% endif %}
30
-
31
- {# edit action #}
32
- {% if session["edit_action"] %}
33
- {% with action = session["edit_action"] %}
34
- <h5> {{ format_name(action['action']) }} </h5>
35
- <form role="form" method='POST' name="{{instrument}}" action="{{ url_for('design.edit_action', uuid=session["edit_action"]['uuid']) }}">
36
- {% if not action['args'] == None %}
37
- <div class="form-group">
38
- {% if not action['args'].__class__.__name__ == 'dict' %}
39
- <div class="input-group mb-3">
40
- <label class="input-group-text">{{ action['action'] }}</label>
41
- <input class="form-control" type="text" id="arg" name="arg" placeholder="{{ action['arg_types']}}" value="{{ action['args'] }}" aria-labelledby="variableHelpBlock">
42
- </div>
43
- {% else %}
44
- {% for arg in action['args'] %}
45
- <div class="input-group mb-3">
46
- <label class="input-group-text">{{ format_name(arg) }}</label>
47
- <input class="form-control" type="text" id="{{ arg }}" name="{{ arg }}" placeholder="{{ action['arg_types'][arg] }}" value="{{ action['args'][arg] }}" aria-labelledby="variableHelpBlock">
48
- </div>
49
- {% endfor %}
50
- <div class="input-group mb-3">
51
- <label class="input-group-text">Save Output?</label>
52
- <input class="form-control" type="text" id="return" name="return" value="{{ action['return'] }}" aria-labelledby="variableHelpBlock">
53
- </div>
54
- {% endif %}
55
- </div>
56
- {% endif %}
57
- <button class="btn btn-primary" type="submit">Save</button>
58
- <button class="btn btn-primary" type="submit" name="back" id="back" value="back">Back</button>
59
- </form>
60
- {% endwith %}
61
- {% elif instrument %}
62
- <div>
63
- <div class="d-flex justify-content-between align-items-center " style="margin-bottom: 1vh;margin-top: 1vh;">
64
-
65
- <a class="btn btn-primary" role="button" type="button" href="{{url_for('design.experiment_builder')}}"><i class="bi bi-arrow-return-left"></i></a>
66
-
67
- {{ format_name(instrument) }}
68
-
69
-
70
- </div>
71
-
72
- <!-- <div class="rounded flex-fill" style="height: 30px;background-color: aliceblue">-->
73
- <!-- <h6 style=" text-align: center; ">{{ format_name(instrument) }}</h6>-->
74
- <!-- </div>-->
75
- {% if instrument in ['if' , 'while' , 'variable' ,'wait'] %}
76
- {# form for builtin functions #}
77
- <form role="form" method='POST' name="{{instrument}}" action="{{url_for('design.experiment_builder',instrument=instrument)}}" >
78
- <div class="form-group">
79
- {{ forms.hidden_tag() }}
80
- {% for field in forms %}
81
- {% if field.type not in ['CSRFTokenField', 'HiddenField'] %}
82
- <div class="input-group mb-3">
83
- <label class="input-group-text">{{ field.label.text }}</label>
84
- {{ field(class="form-control") }}
85
- <div class="form-text">{{ field.description }} </div>
86
- </div>
87
- {% endif %}
88
- {% endfor %}
89
- </div>
90
- <button type="submit" class="btn btn-dark">Add </button>
91
- </form>
92
- {% else %}
93
- {% if script.editing_type == "script" %}
94
- {# Auto Fill Toggle #}
95
- <div class="d-flex justify-content-between align-items-center " style="margin-bottom: 1vh;margin-top: 1vh;">
96
-
97
- <div></div>
98
- <form role="form" method='POST' name="autoFill" id="autoFill">
99
- <div class="form-check form-switch">
100
- <input type="hidden" id="autofill" name="autofill" value="temp_value">
101
- <input class="form-check-input" type="checkbox" id="autoFillCheck" name="autoFillCheck" onchange="document.getElementById('autoFill').submit();"
102
- value="temp_value"
103
- {{ "checked" if session["autofill"] else "" }}>
104
- <label class="form-check-label" for="autoFillCheck">Auto fill</label>
105
- </div>
106
- <button type="submit" class="btn btn-default" style="display: none;">Auto fill </button>
107
- </form>
108
- </div>
109
- {% endif %}
110
-
111
- {# according for instrument #}
112
- <div class="accordion accordion-flush" id="accordionActions" >
113
- {% if use_llm %}
114
- <div class="accordion-item text-to-code">
115
- <h2 class="accordion-header">
116
- <button class="accordion-button text-to-code" type="button" data-bs-toggle="collapse" data-bs-target="#text-to-code" aria-expanded="false" aria-controls="collapseExample">
117
- Text-to-Code
118
- </button>
119
- </h2>
120
- <div id="text-to-code" class="accordion-collapse collapse show" data-bs-parent="#accordionActions">
121
- <div class="accordion-body">
122
- <form role="form" method='POST' name="generate" id="generate" action="{{url_for('design.generate_code')}}">
123
- <input type="hidden" id="instrument" name="instrument" value="{{instrument}}">
124
- <textarea class="form-control" id="prompt" name="prompt" rows="6" aria-describedby="promptHelpBlock">{{ session['prompt'][instrument] if instrument in session['prompt'] else '' }}</textarea>
125
- <div id="promptHelpBlock" class="form-text">
126
- This will overwrite current design.
127
- </div>
128
- <!-- <button type="submit" class="btn btn-dark" id="clear" name="clear" onclick="submitForm('generate')">Clear</button>-->
129
- <button type="submit" class="btn btn-dark" id="gen" name="gen">Generate</button>
130
- </form>
131
- </div>
132
- </div>
133
- </div>
134
- {% endif %}
135
- {% for name, form in forms.items() %}
136
- <div class="accordion-item design-control">
137
- <h2 class="accordion-header">
138
- <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#{{name}}" aria-expanded="false" aria-controls="collapseExample">
139
- {{ format_name(name) }}
140
- </button>
141
- </h2>
142
- <div id="{{name}}" class="accordion-collapse collapse" data-bs-parent="#accordionActions">
143
- <div class="accordion-body">
144
- <form role="form" method='POST' name="add" id="add">
145
- <div class="form-group">
146
- {{ form.hidden_tag() }}
147
- {# {{ form.hidden_name() }}#}
148
- {% for field in form %}
149
- {% if field.type not in ['CSRFTokenField', 'HiddenField'] %}
150
- <div class="input-group mb-3">
151
- <label class="input-group-text">{{ field.label.text }}</label>
152
- {% if field.type == "SubmitField" %}
153
- {{ field(class="btn btn-dark") }}
154
- {% elif field.type == "BooleanField" %}
155
- {{ field(class="form-check-input") }}
156
- {% else %}
157
- {{ field(class="form-control") }}
158
- {% endif %}
159
- </div>
160
- {% endif %}
161
- {% endfor %}
162
- </div>
163
- <button type="submit" class="btn btn-dark">Add </button>
164
- </form>
165
-
166
-
167
- </div>
168
- </div>
169
- </div>
170
- {% endfor %}
171
- </div>
172
- {% endif %}
173
- </div>
174
-
175
-
176
- {# according for all actions #}
177
- {% else %}
178
- <div style="margin-bottom: 4vh;"></div>
179
- <div class="accordion accordion-flush">
180
- <div class="accordion-item design-control">
181
- <h5 class="accordion-header">
182
- <button class="accordion-button" data-bs-toggle="collapse" data-bs-target="#advanced" role="button" aria-expanded="false" aria-controls="collapseExample">
183
- Builtin Operations:
184
- </button>
185
- </h5>
186
- <div class="accordion-collapse collapse show" id="advanced">
187
- <ul class="list-group">
188
- {% for instrument in ['if', 'while', 'variable', 'wait'] %}
189
- <form role="form" method='GET' name="device" action="{{url_for('design.experiment_builder',instrument=instrument)}}">
190
- <div class="form-group">
191
- <button class="list-group-item list-group-item-action" aria-current="true" type="submit">{{instrument}}</button>
192
- </div>
193
- </form>
194
- {% endfor %}
195
- </ul>
196
- </div>
197
- </div>
198
-
199
- <div class="accordion-item design-control">
200
- <h5 class="accordion-header">
201
- <button class="accordion-button" data-bs-toggle="collapse" data-bs-target="#deck" role="button" aria-expanded="false" aria-controls="collapseExample">
202
- Deck Actions:
203
- </button>
204
- </h5>
205
- <div class="accordion-collapse collapse show" id="deck">
206
- <ul class="list-group">
207
- {% for instrument in defined_variables %}
208
- <form role="form" method='GET' name="{{instrument}}" action="{{url_for('design.experiment_builder',instrument=instrument)}}">
209
- <div>
210
- <button class="list-group-item list-group-item-action" type="submit">{{format_name(instrument)}}</button>
211
- </div>
212
- </form>
213
- {% endfor %}
214
- </ul>
215
- </div>
216
- </div>
217
-
218
- {% if local_variables %}
219
- <div class="accordion-item design-control">
220
- <h5 class="accordion-header">
221
- <button class="accordion-button" data-bs-toggle="collapse" data-bs-target="#local" role="button" aria-expanded="false" aria-controls="collapseExample">
222
- Local Actions:
223
- </button>
224
- </h5>
225
- <div class="accordion-collapse collapse show" id="local">
226
- <ul class="list-group">
227
- {% for instrument in local_variables %}
228
- <form role="form" method='GET' name="{{instrument}}" action="{{url_for('design.experiment_builder',instrument=instrument)}}">
229
- <div>
230
- <button class="list-group-item list-group-item-action" type="submit" name="device" value="{{instrument}}" >{{instrument}}</button>
231
- </div>
232
- </form>
233
- {% endfor%}
234
- </ul>
235
- </div>
236
- </div>
237
- {% endif %}
238
- </div>
239
- {% endif %}
240
- </div>
241
-
242
- {# canvas #}
243
- <div class="col-md-9 scroll-column">
244
- <div>
245
- {# file dropdown menu #}
246
- <ul class="nav nav-tabs">
247
- <li class="nav-item dropdown">
248
- <a class="nav-link dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">File tools <i class="bi bi-tools"></i></a>
249
- <ul class="dropdown-menu">
250
- <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#newScriptModal">New</button>
251
- <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#jsonModal">Import (.json <i class="bi bi-filetype-json"></i>)</button>
252
- <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#renameModal">Rename</button>
253
- <a role="button" class="dropdown-item {{'disabled' if not script.name or script.status == 'finalized'}}" type="button" href="{{url_for('database.publish')}}">Save</a></li>
254
- <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#saveasModal">Save as</button>
255
- {% if not script.status == 'finalized' %}
256
- <a role="button" class="dropdown-item" type="button" href="{{url_for('database.finalize')}}">Disable editing</a>
257
- {% endif %}
258
- <a class="dropdown-item" role="button" type="button" href="{{url_for('design.download', filetype='script')}}">Export (.json <i class="bi bi-filetype-json"></i>)</a>
259
- </ul>
260
- </li>
261
-
262
- <li class="nav-item"><a class="nav-link" aria-current="page" data-bs-toggle="collapse" href="#info">Info</a></li>
263
- <li class="nav-item"><a class="{{'nav-link active' if script.editing_type=='prep' else 'nav-link'}}" aria-current="page" href="{{url_for('design.toggle_script_type', stype='prep') }}">Prep</a></li>
264
- <li class="nav-item"><a class="{{'nav-link active' if script.editing_type=='script' else 'nav-link'}}" aria-current="page" href="{{url_for('design.toggle_script_type', stype='script') }}">Experiment</a></li>
265
- <li class="nav-item"><a class="{{'nav-link active' if script.editing_type=='cleanup' else 'nav-link'}}" aria-current="page" href="{{url_for('design.toggle_script_type', stype='cleanup') }}">Clean up</a></li>
266
- </ul>
267
- </div>
268
-
269
- <div class="canvas">
270
- <div class="collapse" id="info">
271
- <table class="table script-table">
272
- <tbody>
273
- <tr><th scope="row">Deck Name</th><td>{{script.deck}}</td></tr>
274
- <tr><th scope="row">Script Name</th><td>{{ script.name }}</td></tr>
275
- <tr>
276
- <th scope="row">Editing status <a role="button" data-bs-toggle="popover" data-bs-title="How to use:" data-bs-content="You can choose to disable editing, so the script is finalized and cannot be edited. Use save as to rename the script"><i class="bi bi-info-circle"></i></a></th>
277
- <td>{{script.status}}</td>
278
- </tr>
279
- <tr>
280
- <th scope="row">Output Values <a role="button" data-bs-toggle="popover" data-bs-title="How to use:" data-bs-content="This will be your output data. If the return data is not a value, it will save as None is the result file"><i class="bi bi-info-circle"></i></a></th>
281
- <td>
282
- {% for i in script.config_return()[1] %}
283
- <input type="checkbox">{{i}}
284
- {% endfor %}
285
- </td>
286
- </tr>
287
- <tr>
288
- <th scope="row">Config Variables <a role="button" data-bs-toggle="popover" data-bs-title="How to use:" data-bs-content="This shows variables you want to configure later using .csv file"><i class="bi bi-info-circle"></i></a></th>
289
- <td>
290
- <ul>
291
- {% for i in script.config("script")[0] %}
292
- <li>{{i}}</li>
293
- {% endfor %}
294
- </ul>
295
- </td>
296
- </tr>
297
- </tbody>
298
- </table>
299
- </div>
300
- <div class="list-group" id="list" style="margin-top: 20px">
301
- <ul class="reorder">
302
- {% for button in buttons %}
303
- <li id="{{ button['id'] }}" style="list-style-type: none;">
304
- <a href="{{ url_for('design.edit_action', uuid=button['uuid']) }}" type="button" class="btn btn-light" style="{{ button['style'] }}">{{ button['label'] }}</a>
305
- {% if not button["instrument"] in ["if","while"] %}
306
- <a href="{{ url_for('design.duplicate_action', id=button['id']) }}" type="button" class="btn btn-light"><span class="bi bi-copy"></span></a>
307
- {% endif %}
308
- <a href="{{ url_for('design.delete_action', id=button['id']) }}" type="button" class="btn btn-light"><span class="bi bi-trash"></span></a>
309
- </li>
310
- {% endfor %}
311
- </ul>
312
-
313
- </div>
314
- </div>
315
- <div>
316
- <a class="btn btn-dark {{ 'disabled' if not script.name or script.status == "finalized" else ''}}" href="{{url_for('database.publish')}}">Quick Save</a>
317
- <a class="btn btn-dark " href="{{ url_for('design.experiment_run') }}">Compile and Run</a>
318
- </div>
319
- </div>
320
- </div>
321
-
322
- {# modals #}
323
- <div class="modal fade" id="newScriptModal" tabindex="-1" aria-labelledby="newScriptModalLabel" aria-hidden="true">
324
- <div class="modal-dialog">
325
- <div class="modal-content">
326
- <div class="modal-header">
327
- <h1 class="modal-title fs-5" id="newScriptModalLabel">Save your current editing!</h1>
328
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
329
- </div>
330
- <div class="modal-body">
331
- The current editing won't be saved. Are you sure you want to proceed?
332
- </div>
333
- <div class="modal-footer">
334
- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Continue editing </button>
335
- <a role="button" class="btn btn-primary" href="{{url_for('design.clear')}}"> Already saved, clear all </a>
336
- </div>
337
- </div>
338
- </div>
339
- </div>
340
- <div class="modal fade" id="saveasModal" tabindex="-1" aria-labelledby="saveasModal" aria-hidden="true" >
341
- <div class="modal-dialog">
342
- <div class="modal-content">
343
- <div class="modal-header">
344
- <h1 class="modal-title fs-5" id="saveasModal">Save your script as </h1>
345
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
346
- </div>
347
- <form method="POST" name="run_name" action="{{ url_for('database.save_as') }}">
348
- <div class="modal-body">
349
- <div class="input-group mb-3">
350
- <label class="input-group-text" for="run_name">Run Name</label>
351
- <input class="form-control" type="text" name="run_name" id="run_name" placeholder="{{script['name']}}" required="required">
352
- </div>
353
- </div>
354
- <div class="modal-footer">
355
- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Close </button>
356
- <button type="submit" class="btn btn-primary"> Save </button>
357
- </div>
358
- </form>
359
- </div>
360
- </div>
361
- </div>
362
- <div class="modal fade" id="renameModal" tabindex="-1" aria-labelledby="renameModal" aria-hidden="true" >
363
- <div class="modal-dialog">
364
- <div class="modal-content">
365
- <div class="modal-header">
366
- <h1 class="modal-title fs-5" id="renameModal">Rename your script</h1>
367
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
368
- </div>
369
- <form method="POST" name="run_name" action="{{ url_for('database.edit_run_name') }}">
370
- <div class="modal-body">
371
- <div class="input-group mb-3">
372
- <label class="input-group-text" for="run_name">Run Name</label>
373
- <input class="form-control" type="text" name="run_name" id="run_name" placeholder="{{script['name']}}" required="required">
374
- </div>
375
- </div>
376
- <div class="modal-footer">
377
- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Close </button>
378
- <button type="submit" class="btn btn-primary"> Save </button>
379
- </div>
380
- </form>
381
- </div>
382
- </div>
383
- </div>
384
- <div class="modal fade" id="jsonModal" tabindex="-1" aria-labelledby="jsonModal" aria-hidden="true" >
385
- <div class="modal-dialog">
386
- <div class="modal-content">
387
- <div class="modal-header">
388
- <h1 class="modal-title fs-5" id="jsonModal">Import from JSON</h1>
389
- <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
390
- </div>
391
- <form method="POST" action="{{ url_for('design.load_json') }}" enctype="multipart/form-data">
392
- <div class="modal-body">
393
- <div class="input-group mb-3">
394
- <input class="form-control" type="file" name="file" required="required">
395
- </div>
396
- </div>
397
- <div class="modal-footer">
398
- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Close </button>
399
- <button type="submit" class="btn btn-primary"> Upload </button>
400
- </div>
401
- </form>
402
- </div>
403
- </div>
404
- </div>
405
-
406
- {% if instrument and not instrument in ['if' , 'while' , 'variable' ,'wait'] and use_llm %}
407
- <script>
408
- const buttonIds = {{ ['generate'] | tojson }};
409
- </script>
410
- <script src="{{ url_for('static', filename='js/overlay.js') }}"></script>
411
- {% endif %}
412
- <script>
413
- const updateListUrl = "{{ url_for('design.update_list') }}";
414
- </script>
415
- <script src="{{ url_for('static', filename='js/sortable_design.js') }}"></script>
1
+ {% extends 'base.html' %}
2
+ {% block title %}IvoryOS | Design{% endblock %}
3
+
4
+ {% block body %}
5
+ {# <div id="overlay" class="overlay">Generating design, please wait...</div>#}
6
+ <div id="overlay" class="overlay">
7
+ <div>
8
+ <h3 id="overlay-text">Generating design, please wait...</h3>
9
+ <div class="spinner-border" role="status"></div>
10
+ </div>
11
+ </div>
12
+ <div class="row">
13
+ <div class="col-md-3 scroll-column" >
14
+
15
+ {# select deck if this is online#}
16
+ {% if off_line %}
17
+ <form id="select-deck" method="POST" action="{{ url_for('design.import_pseudo') }}" enctype="multipart/form-data">
18
+ <div class="input-group mb-3">
19
+ {# <label for="pkl_name" class="form-label">Choose/Change deck:</label>#}
20
+ <select class="form-select" name="pkl_name" id="pkl_name" required onchange="document.getElementById('select-deck').submit();">
21
+ <option {{ '' if 'pseudo_deck' in session else 'selected' }} disabled hidden style="overflow-wrap: break-word;" name="pkl_name" id="pkl_name" value=""> -- choose deck --</option>
22
+ {% for connection in history %}
23
+ <option {{ 'selected' if session['pseudo_deck']==connection else '' }} style="overflow-wrap: break-word;" name="pkl_name" id="pkl_name" value="{{connection}}">{{connection.split('.')[0]}}</option>
24
+ {% endfor %}
25
+ </select>
26
+ </div>
27
+ </form>
28
+ <hr>
29
+ {% endif %}
30
+
31
+ {# edit action #}
32
+ {% if session["edit_action"] %}
33
+ {% with action = session["edit_action"] %}
34
+ <h5> {{ format_name(action['action']) }} </h5>
35
+ <form role="form" method='POST' name="{{instrument}}" action="{{ url_for('design.edit_action', uuid=session["edit_action"]['uuid']) }}">
36
+ {% if not action['args'] == None %}
37
+ <div class="form-group">
38
+ {% if not action['args'].__class__.__name__ == 'dict' %}
39
+ <div class="input-group mb-3">
40
+ <label class="input-group-text">{{ action['action'] }}</label>
41
+ <input class="form-control" type="text" id="arg" name="arg" placeholder="{{ action['arg_types']}}" value="{{ action['args'] }}" aria-labelledby="variableHelpBlock">
42
+ </div>
43
+ {% else %}
44
+ {% for arg in action['args'] %}
45
+ <div class="input-group mb-3">
46
+ <label class="input-group-text">{{ format_name(arg) }}</label>
47
+ <input class="form-control" type="text" id="{{ arg }}" name="{{ arg }}" placeholder="{{ action['arg_types'][arg] }}" value="{{ action['args'][arg] }}" aria-labelledby="variableHelpBlock">
48
+ </div>
49
+ {% endfor %}
50
+ <div class="input-group mb-3">
51
+ <label class="input-group-text">Save Output?</label>
52
+ <input class="form-control" type="text" id="return" name="return" value="{{ action['return'] }}" aria-labelledby="variableHelpBlock">
53
+ </div>
54
+ {% endif %}
55
+ </div>
56
+ {% endif %}
57
+ <button class="btn btn-primary" type="submit">Save</button>
58
+ <button class="btn btn-primary" type="submit" name="back" id="back" value="back">Back</button>
59
+ </form>
60
+ {% endwith %}
61
+ {% elif instrument %}
62
+ <div>
63
+ <div class="d-flex justify-content-between align-items-center " style="margin-bottom: 1vh;margin-top: 1vh;">
64
+
65
+ <a class="btn btn-primary" role="button" type="button" href="{{url_for('design.experiment_builder')}}"><i class="bi bi-arrow-return-left"></i></a>
66
+
67
+ {{ format_name(instrument) }}
68
+
69
+
70
+ </div>
71
+
72
+ <!-- <div class="rounded flex-fill" style="height: 30px;background-color: aliceblue">-->
73
+ <!-- <h6 style=" text-align: center; ">{{ format_name(instrument) }}</h6>-->
74
+ <!-- </div>-->
75
+ {% if instrument in ['if' , 'while' , 'variable' ,'wait', 'repeat'] %}
76
+ {# form for builtin functions #}
77
+ <form role="form" method='POST' name="{{instrument}}" action="{{url_for('design.experiment_builder',instrument=instrument)}}" >
78
+ <div class="form-group">
79
+ {{ forms.hidden_tag() }}
80
+ {% for field in forms %}
81
+ {% if field.type not in ['CSRFTokenField', 'HiddenField'] %}
82
+ <div class="input-group mb-3">
83
+ <label class="input-group-text">{{ field.label.text }}</label>
84
+ {{ field(class="form-control") }}
85
+ <div class="form-text">{{ field.description }} </div>
86
+ </div>
87
+ {% endif %}
88
+ {% endfor %}
89
+ </div>
90
+ <button type="submit" class="btn btn-dark">Add </button>
91
+ </form>
92
+ {% else %}
93
+ {% if script.editing_type == "script" %}
94
+ {# Auto Fill Toggle #}
95
+ <div class="d-flex justify-content-between align-items-center " style="margin-bottom: 1vh;margin-top: 1vh;">
96
+
97
+ <div></div>
98
+ <form role="form" method='POST' name="autoFill" id="autoFill">
99
+ <div class="form-check form-switch">
100
+ <input type="hidden" id="autofill" name="autofill" value="temp_value">
101
+ <input class="form-check-input" type="checkbox" id="autoFillCheck" name="autoFillCheck" onchange="document.getElementById('autoFill').submit();"
102
+ value="temp_value"
103
+ {{ "checked" if session["autofill"] else "" }}>
104
+ <label class="form-check-label" for="autoFillCheck">Auto fill</label>
105
+ </div>
106
+ <button type="submit" class="btn btn-default" style="display: none;">Auto fill </button>
107
+ </form>
108
+ </div>
109
+ {% endif %}
110
+
111
+ {# according for instrument #}
112
+ <div class="accordion accordion-flush" id="accordionActions" >
113
+ {% if use_llm %}
114
+ <div class="accordion-item text-to-code">
115
+ <h2 class="accordion-header">
116
+ <button class="accordion-button text-to-code" type="button" data-bs-toggle="collapse" data-bs-target="#text-to-code" aria-expanded="false" aria-controls="collapseExample">
117
+ Text-to-Code
118
+ </button>
119
+ </h2>
120
+ <div id="text-to-code" class="accordion-collapse collapse show" data-bs-parent="#accordionActions">
121
+ <div class="accordion-body">
122
+ <form role="form" method='POST' name="generate" id="generate" action="{{url_for('design.generate_code')}}">
123
+ <input type="hidden" id="instrument" name="instrument" value="{{instrument}}">
124
+ <textarea class="form-control" id="prompt" name="prompt" rows="6" aria-describedby="promptHelpBlock">{{ session['prompt'][instrument] if instrument in session['prompt'] else '' }}</textarea>
125
+ <div id="promptHelpBlock" class="form-text">
126
+ This will overwrite current design.
127
+ </div>
128
+ <!-- <button type="submit" class="btn btn-dark" id="clear" name="clear" onclick="submitForm('generate')">Clear</button>-->
129
+ <button type="submit" class="btn btn-dark" id="gen" name="gen">Generate</button>
130
+ </form>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ {% endif %}
135
+ {% for name, form in forms.items() %}
136
+ <div class="accordion-item design-control">
137
+ <h2 class="accordion-header">
138
+ <button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#{{name}}" aria-expanded="false" aria-controls="collapseExample">
139
+ {{ format_name(name) }}
140
+ </button>
141
+ </h2>
142
+ <div id="{{name}}" class="accordion-collapse collapse" data-bs-parent="#accordionActions">
143
+ <div class="accordion-body">
144
+ <form role="form" method='POST' name="add" id="add">
145
+ <div class="form-group">
146
+ {{ form.hidden_tag() }}
147
+ {# {{ form.hidden_name() }}#}
148
+ {% for field in form %}
149
+ {% if field.type not in ['CSRFTokenField', 'HiddenField'] %}
150
+ <div class="input-group mb-3">
151
+ <label class="input-group-text">{{ field.label.text }}</label>
152
+ {% if field.type == "SubmitField" %}
153
+ {{ field(class="btn btn-dark") }}
154
+ {% elif field.type == "BooleanField" %}
155
+ {{ field(class="form-check-input") }}
156
+ {% else %}
157
+ {{ field(class="form-control") }}
158
+ {% endif %}
159
+ </div>
160
+ {% endif %}
161
+ {% endfor %}
162
+ </div>
163
+ <button type="submit" class="btn btn-dark">Add </button>
164
+ </form>
165
+
166
+
167
+ </div>
168
+ </div>
169
+ </div>
170
+ {% endfor %}
171
+ </div>
172
+ {% endif %}
173
+ </div>
174
+
175
+
176
+ {# according for all actions #}
177
+ {% else %}
178
+ <div style="margin-bottom: 4vh;"></div>
179
+ <div class="accordion accordion-flush">
180
+ <div class="accordion-item design-control">
181
+ <h5 class="accordion-header">
182
+ <button class="accordion-button" data-bs-toggle="collapse" data-bs-target="#advanced" role="button" aria-expanded="false" aria-controls="collapseExample">
183
+ Builtin Operations:
184
+ </button>
185
+ </h5>
186
+ <div class="accordion-collapse collapse show" id="advanced">
187
+ <ul class="list-group">
188
+ {% for instrument in ['if', 'while', 'variable', 'wait', 'repeat'] %}
189
+ <form role="form" method='GET' name="device" action="{{url_for('design.experiment_builder',instrument=instrument)}}">
190
+ <div class="form-group">
191
+ <button class="list-group-item list-group-item-action" aria-current="true" type="submit">{{instrument}}</button>
192
+ </div>
193
+ </form>
194
+ {% endfor %}
195
+ </ul>
196
+ </div>
197
+ </div>
198
+
199
+ <div class="accordion-item design-control">
200
+ <h5 class="accordion-header">
201
+ <button class="accordion-button" data-bs-toggle="collapse" data-bs-target="#deck" role="button" aria-expanded="false" aria-controls="collapseExample">
202
+ Deck Actions:
203
+ </button>
204
+ </h5>
205
+ <div class="accordion-collapse collapse show" id="deck">
206
+ <ul class="list-group">
207
+ {% for instrument in defined_variables %}
208
+ <form role="form" method='GET' name="{{instrument}}" action="{{url_for('design.experiment_builder',instrument=instrument)}}">
209
+ <div>
210
+ <button class="list-group-item list-group-item-action" type="submit">{{format_name(instrument)}}</button>
211
+ </div>
212
+ </form>
213
+ {% endfor %}
214
+ </ul>
215
+ </div>
216
+ </div>
217
+
218
+ {% if local_variables %}
219
+ <div class="accordion-item design-control">
220
+ <h5 class="accordion-header">
221
+ <button class="accordion-button" data-bs-toggle="collapse" data-bs-target="#local" role="button" aria-expanded="false" aria-controls="collapseExample">
222
+ Local Actions:
223
+ </button>
224
+ </h5>
225
+ <div class="accordion-collapse collapse show" id="local">
226
+ <ul class="list-group">
227
+ {% for instrument in local_variables %}
228
+ <form role="form" method='GET' name="{{instrument}}" action="{{url_for('design.experiment_builder',instrument=instrument)}}">
229
+ <div>
230
+ <button class="list-group-item list-group-item-action" type="submit" name="device" value="{{instrument}}" >{{instrument}}</button>
231
+ </div>
232
+ </form>
233
+ {% endfor%}
234
+ </ul>
235
+ </div>
236
+ </div>
237
+ {% endif %}
238
+ </div>
239
+ {% endif %}
240
+ </div>
241
+
242
+ {# canvas #}
243
+ <div class="col-md-9 scroll-column">
244
+ <div>
245
+ {# file dropdown menu #}
246
+ <ul class="nav nav-tabs">
247
+ <li class="nav-item dropdown">
248
+ <a class="nav-link dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">File tools <i class="bi bi-tools"></i></a>
249
+ <ul class="dropdown-menu">
250
+ <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#newScriptModal">New</button>
251
+ <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#jsonModal">Import (.json <i class="bi bi-filetype-json"></i>)</button>
252
+ <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#renameModal">Rename</button>
253
+ <a role="button" class="dropdown-item {{'disabled' if not script.name or script.status == 'finalized'}}" type="button" href="{{url_for('database.publish')}}">Save</a></li>
254
+ <button class="dropdown-item" type="button" data-bs-toggle="modal" data-bs-target="#saveasModal">Save as</button>
255
+ {% if not script.status == 'finalized' %}
256
+ <a role="button" class="dropdown-item" type="button" href="{{url_for('database.finalize')}}">Disable editing</a>
257
+ {% endif %}
258
+ <a class="dropdown-item" role="button" type="button" href="{{url_for('design.download', filetype='script')}}">Export (.json <i class="bi bi-filetype-json"></i>)</a>
259
+ </ul>
260
+ </li>
261
+
262
+ <li class="nav-item"><a class="nav-link" aria-current="page" data-bs-toggle="collapse" href="#info">Info</a></li>
263
+ <li class="nav-item"><a class="{{'nav-link active' if script.editing_type=='prep' else 'nav-link'}}" aria-current="page" href="{{url_for('design.toggle_script_type', stype='prep') }}">Prep</a></li>
264
+ <li class="nav-item"><a class="{{'nav-link active' if script.editing_type=='script' else 'nav-link'}}" aria-current="page" href="{{url_for('design.toggle_script_type', stype='script') }}">Experiment</a></li>
265
+ <li class="nav-item"><a class="{{'nav-link active' if script.editing_type=='cleanup' else 'nav-link'}}" aria-current="page" href="{{url_for('design.toggle_script_type', stype='cleanup') }}">Clean up</a></li>
266
+ </ul>
267
+ </div>
268
+
269
+ <div class="canvas">
270
+ <div class="collapse" id="info">
271
+ <table class="table script-table">
272
+ <tbody>
273
+ <tr><th scope="row">Deck Name</th><td>{{script.deck}}</td></tr>
274
+ <tr><th scope="row">Script Name</th><td>{{ script.name }}</td></tr>
275
+ <tr>
276
+ <th scope="row">Editing status <a role="button" data-bs-toggle="popover" data-bs-title="How to use:" data-bs-content="You can choose to disable editing, so the script is finalized and cannot be edited. Use save as to rename the script"><i class="bi bi-info-circle"></i></a></th>
277
+ <td>{{script.status}}</td>
278
+ </tr>
279
+ <tr>
280
+ <th scope="row">Output Values <a role="button" data-bs-toggle="popover" data-bs-title="How to use:" data-bs-content="This will be your output data. If the return data is not a value, it will save as None is the result file"><i class="bi bi-info-circle"></i></a></th>
281
+ <td>
282
+ {% for i in script.config_return()[1] %}
283
+ <input type="checkbox">{{i}}
284
+ {% endfor %}
285
+ </td>
286
+ </tr>
287
+ <tr>
288
+ <th scope="row">Config Variables <a role="button" data-bs-toggle="popover" data-bs-title="How to use:" data-bs-content="This shows variables you want to configure later using .csv file"><i class="bi bi-info-circle"></i></a></th>
289
+ <td>
290
+ <ul>
291
+ {% for i in script.config("script")[0] %}
292
+ <li>{{i}}</li>
293
+ {% endfor %}
294
+ </ul>
295
+ </td>
296
+ </tr>
297
+ </tbody>
298
+ </table>
299
+ </div>
300
+ <div class="list-group" id="list" style="margin-top: 20px">
301
+ <ul class="reorder">
302
+ {% for button in buttons %}
303
+ <li id="{{ button['id'] }}" style="list-style-type: none;">
304
+ <a href="{{ url_for('design.edit_action', uuid=button['uuid']) }}" type="button" class="btn btn-light" style="{{ button['style'] }}">{{ button['label'] }}</a>
305
+ {% if not button["instrument"] in ["if","while","repeat"] %}
306
+ <a href="{{ url_for('design.duplicate_action', id=button['id']) }}" type="button" class="btn btn-light"><span class="bi bi-copy"></span></a>
307
+ {% endif %}
308
+ <a href="{{ url_for('design.delete_action', id=button['id']) }}" type="button" class="btn btn-light"><span class="bi bi-trash"></span></a>
309
+ </li>
310
+ {% endfor %}
311
+ </ul>
312
+
313
+ </div>
314
+ </div>
315
+ <div>
316
+ <a class="btn btn-dark {{ 'disabled' if not script.name or script.status == "finalized" else ''}}" href="{{url_for('database.publish')}}">Quick Save</a>
317
+ <a class="btn btn-dark " href="{{ url_for('design.experiment_run') }}">Compile and Run</a>
318
+ </div>
319
+ </div>
320
+ </div>
321
+
322
+ {# modals #}
323
+ <div class="modal fade" id="newScriptModal" tabindex="-1" aria-labelledby="newScriptModalLabel" aria-hidden="true">
324
+ <div class="modal-dialog">
325
+ <div class="modal-content">
326
+ <div class="modal-header">
327
+ <h1 class="modal-title fs-5" id="newScriptModalLabel">Save your current editing!</h1>
328
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
329
+ </div>
330
+ <div class="modal-body">
331
+ The current editing won't be saved. Are you sure you want to proceed?
332
+ </div>
333
+ <div class="modal-footer">
334
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Continue editing </button>
335
+ <a role="button" class="btn btn-primary" href="{{url_for('design.clear')}}"> Already saved, clear all </a>
336
+ </div>
337
+ </div>
338
+ </div>
339
+ </div>
340
+ <div class="modal fade" id="saveasModal" tabindex="-1" aria-labelledby="saveasModal" aria-hidden="true" >
341
+ <div class="modal-dialog">
342
+ <div class="modal-content">
343
+ <div class="modal-header">
344
+ <h1 class="modal-title fs-5" id="saveasModal">Save your script as </h1>
345
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
346
+ </div>
347
+ <form method="POST" name="run_name" action="{{ url_for('database.save_as') }}">
348
+ <div class="modal-body">
349
+ <div class="input-group mb-3">
350
+ <label class="input-group-text" for="run_name">Run Name</label>
351
+ <input class="form-control" type="text" name="run_name" id="run_name" placeholder="{{script['name']}}" required="required">
352
+ </div>
353
+ </div>
354
+ <div class="modal-footer">
355
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Close </button>
356
+ <button type="submit" class="btn btn-primary"> Save </button>
357
+ </div>
358
+ </form>
359
+ </div>
360
+ </div>
361
+ </div>
362
+ <div class="modal fade" id="renameModal" tabindex="-1" aria-labelledby="renameModal" aria-hidden="true" >
363
+ <div class="modal-dialog">
364
+ <div class="modal-content">
365
+ <div class="modal-header">
366
+ <h1 class="modal-title fs-5" id="renameModal">Rename your script</h1>
367
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
368
+ </div>
369
+ <form method="POST" name="run_name" action="{{ url_for('database.edit_run_name') }}">
370
+ <div class="modal-body">
371
+ <div class="input-group mb-3">
372
+ <label class="input-group-text" for="run_name">Run Name</label>
373
+ <input class="form-control" type="text" name="run_name" id="run_name" placeholder="{{script['name']}}" required="required">
374
+ </div>
375
+ </div>
376
+ <div class="modal-footer">
377
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Close </button>
378
+ <button type="submit" class="btn btn-primary"> Save </button>
379
+ </div>
380
+ </form>
381
+ </div>
382
+ </div>
383
+ </div>
384
+ <div class="modal fade" id="jsonModal" tabindex="-1" aria-labelledby="jsonModal" aria-hidden="true" >
385
+ <div class="modal-dialog">
386
+ <div class="modal-content">
387
+ <div class="modal-header">
388
+ <h1 class="modal-title fs-5" id="jsonModal">Import from JSON</h1>
389
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
390
+ </div>
391
+ <form method="POST" action="{{ url_for('design.load_json') }}" enctype="multipart/form-data">
392
+ <div class="modal-body">
393
+ <div class="input-group mb-3">
394
+ <input class="form-control" type="file" name="file" required="required">
395
+ </div>
396
+ </div>
397
+ <div class="modal-footer">
398
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"> Close </button>
399
+ <button type="submit" class="btn btn-primary"> Upload </button>
400
+ </div>
401
+ </form>
402
+ </div>
403
+ </div>
404
+ </div>
405
+
406
+ {% if instrument and not instrument in ['if' , 'while' , 'variable' ,'wait', 'repeat'] and use_llm %}
407
+ <script>
408
+ const buttonIds = {{ ['generate'] | tojson }};
409
+ </script>
410
+ <script src="{{ url_for('static', filename='js/overlay.js') }}"></script>
411
+ {% endif %}
412
+ <script>
413
+ const updateListUrl = "{{ url_for('design.update_list') }}";
414
+ </script>
415
+ <script src="{{ url_for('static', filename='js/sortable_design.js') }}"></script>
416
416
  {% endblock %}