LennardZuendorf commited on
Commit
31b505c
1 Parent(s): 13ba461

feat: updating explanation component, adding iFrame again, other improvements

Browse files
.idea/thesis-webapp.iml CHANGED
@@ -6,6 +6,7 @@
6
  <sourceFolder url="file://$MODULE_DIR$/components/shap-plots/backend" isTestSource="false" />
7
  <sourceFolder url="file://$MODULE_DIR$/components/shap/backend" isTestSource="false" />
8
  <sourceFolder url="file://$MODULE_DIR$/components/visualizer/backend" isTestSource="false" />
 
9
  </content>
10
  <orderEntry type="jdk" jdkName="Python 3.11.6 WSL (Ubuntu): (/home/lennard/.virtualenvs/thesis/bin/python)" jdkType="Python SDK" />
11
  <orderEntry type="sourceFolder" forTests="false" />
 
6
  <sourceFolder url="file://$MODULE_DIR$/components/shap-plots/backend" isTestSource="false" />
7
  <sourceFolder url="file://$MODULE_DIR$/components/shap/backend" isTestSource="false" />
8
  <sourceFolder url="file://$MODULE_DIR$/components/visualizer/backend" isTestSource="false" />
9
+ <sourceFolder url="file://$MODULE_DIR$/components/iframe/backend" isTestSource="false" />
10
  </content>
11
  <orderEntry type="jdk" jdkName="Python 3.11.6 WSL (Ubuntu): (/home/lennard/.virtualenvs/thesis/bin/python)" jdkType="Python SDK" />
12
  <orderEntry type="sourceFolder" forTests="false" />
backend/database.py ADDED
File without changes
components/iframe/README.md CHANGED
@@ -1,10 +1,36 @@
1
-
2
  # gradio_iframe
3
- A Custom Gradio component.
 
 
 
 
 
 
4
 
5
- ## Example usage
 
 
6
 
7
  ```python
8
  import gradio as gr
9
- from gradio_iframe import iframe
 
 
 
 
 
 
 
10
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # gradio_iframe
2
+ A custom gradio component to embed an iframe in a gradio interface. This component is based on the [HTML]() component.
3
+ It's currently still a work in progress.
4
+
5
+ ## Usage
6
+
7
+ The usage is similar to the HTML component. You can pass valid html and it will be rendered in the interface as an iframe, meaning you can embed any website or webapp that supports iframes.
8
+ Also, JavaScript should run normal.
9
 
10
+ You can still pass normal html that's not interactive.
11
+
12
+ ### Example
13
 
14
  ```python
15
  import gradio as gr
16
+ from gradio_iframe import iFrame
17
+
18
+ gr.Interface(
19
+ iFrame(
20
+ label="iFrame Example",
21
+ value=("https://www.youtube.com/watch?v=dQw4w9WgXcQ"),
22
+ show_label=True)
23
+ )
24
  ```
25
+
26
+ ## Known Issues
27
+
28
+ **There are many reason why it's not a good idea to embed websites in an iframe.**
29
+ See [this](https://blog.bitsrc.io/4-security-concerns-with-iframes-every-web-developer-should-know-24c73e6a33e4), or just google "iframe security concerns" for more information. Also, iFrames will use additional computing power and memory, which can slow down the interface.
30
+
31
+ Also this component is still a work in progress and not fully tested. Use at your own risk.
32
+
33
+ ### Other Issues
34
+
35
+ - Height does not grow according to the inner component.
36
+ - ...
components/iframe/backend/gradio_iframe/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
 
2
- from .iframe import iframe
3
 
4
- __all__ = ['iframe']
 
1
 
2
+ from .iframe import iFrame
3
 
4
+ __all__ = ['iFrame']
components/iframe/backend/gradio_iframe/iframe.py CHANGED
@@ -13,11 +13,11 @@ set_documentation_group("component")
13
 
14
 
15
  @document()
16
- class iframe(Component):
17
  """
18
- Used to display arbitrary iframe output.
19
  Preprocessing: this component does *not* accept input.
20
- Postprocessing: expects valid html {str}, which will be turned into an iframe.
21
 
22
  Demos: text_analysis
23
  Guides: key-features
@@ -44,8 +44,8 @@ class iframe(Component):
44
  every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
45
  show_label: This parameter has no effect.
46
  visible: If False, component will be hidden.
47
- elem_id: An optional string that is assigned as the id of this component in the iframe DOM. Can be used for targeting CSS styles.
48
- elem_classes: An optional list of strings that are assigned as the classes of this component in the iframe DOM. Can be used for targeting CSS styles.
49
  render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
50
  """
51
  super().__init__(
 
13
 
14
 
15
  @document()
16
+ class iFrame(Component):
17
  """
18
+ Used to display abitrary html output.
19
  Preprocessing: this component does *not* accept input.
20
+ Postprocessing: expects a valid HTML {str}.
21
 
22
  Demos: text_analysis
23
  Guides: key-features
 
44
  every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
45
  show_label: This parameter has no effect.
46
  visible: If False, component will be hidden.
47
+ elem_id: An optional string that is assigned as the id of this component in the iFrame DOM. Can be used for targeting CSS styles.
48
+ elem_classes: An optional list of strings that are assigned as the classes of this component in the iFrame DOM. Can be used for targeting CSS styles.
49
  render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
50
  """
51
  super().__init__(
components/iframe/backend/gradio_iframe/templates/component/index.js CHANGED
@@ -19,7 +19,7 @@ function _t(n) {
19
  "srcdoc",
20
  /*value*/
21
  n[1]
22
- ), B(e, "allow", ""), B(t, "class", l = "prose " + /*elem_classes*/
23
  n[0].join(" ") + " svelte-2qygph"), x(
24
  t,
25
  "min",
@@ -57,7 +57,7 @@ function _t(n) {
57
  }
58
  };
59
  }
60
- function ut(n, t, e) {
61
  let { elem_classes: l = [] } = t, { value: i } = t, { visible: f = !0 } = t, { min_height: o = !1 } = t;
62
  const a = rt();
63
  return n.$$set = (r) => {
@@ -67,9 +67,9 @@ function ut(n, t, e) {
67
  2 && a("change");
68
  }, [l, i, f, o];
69
  }
70
- class ct extends nt {
71
  constructor(t) {
72
- super(), ft(this, t, ut, _t, at, {
73
  elem_classes: 0,
74
  value: 1,
75
  visible: 2,
@@ -158,24 +158,24 @@ function fe(n, t, e, l) {
158
  }
159
  function ke(n, t = {}) {
160
  const e = bt(n), { stiffness: l = 0.15, damping: i = 0.8, precision: f = 0.01 } = t;
161
- let o, a, r, s = n, _ = n, c = 1, w = 0, h = !1;
162
  function p(k, L = {}) {
163
  _ = k;
164
  const F = r = {};
165
- return n == null || L.hard || C.stiffness >= 1 && C.damping >= 1 ? (h = !0, o = pe(), s = k, e.set(n = _), Promise.resolve()) : (L.soft && (w = 1 / ((L.soft === !0 ? 0.5 : +L.soft) * 60), c = 0), a || (o = pe(), h = !1, a = mt((u) => {
166
  if (h)
167
  return h = !1, a = null, !1;
168
- c = Math.min(c + w, 1);
169
  const y = {
170
- inv_mass: c,
171
  opts: C,
172
  settled: !0,
173
- dt: (u - o) * 60 / 1e3
174
  }, m = fe(y, s, n, _);
175
- return o = u, s = n, e.set(n = m), y.settled && (a = null), !y.settled;
176
- })), new Promise((u) => {
177
  a.promise.then(() => {
178
- F === r && u();
179
  });
180
  }));
181
  }
@@ -205,12 +205,12 @@ const {
205
  toggle_class: Le
206
  } = window.__gradio__svelte__internal, { onMount: kt } = window.__gradio__svelte__internal;
207
  function qt(n) {
208
- let t, e, l, i, f, o, a, r, s, _, c, w;
209
  return {
210
  c() {
211
- t = wt("div"), e = z("svg"), l = z("g"), i = z("path"), f = z("path"), o = z("path"), a = z("path"), r = z("g"), s = z("path"), _ = z("path"), c = z("path"), w = z("path"), v(i, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), v(i, "fill", "#FF7C00"), v(i, "fill-opacity", "0.4"), v(i, "class", "svelte-43sxxs"), v(f, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), v(f, "fill", "#FF7C00"), v(f, "class", "svelte-43sxxs"), v(o, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), v(o, "fill", "#FF7C00"), v(o, "fill-opacity", "0.4"), v(o, "class", "svelte-43sxxs"), v(a, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), v(a, "fill", "#FF7C00"), v(a, "class", "svelte-43sxxs"), $(l, "transform", "translate(" + /*$top*/
212
  n[1][0] + "px, " + /*$top*/
213
- n[1][1] + "px)"), v(s, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), v(s, "fill", "#FF7C00"), v(s, "fill-opacity", "0.4"), v(s, "class", "svelte-43sxxs"), v(_, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), v(_, "fill", "#FF7C00"), v(_, "class", "svelte-43sxxs"), v(c, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), v(c, "fill", "#FF7C00"), v(c, "fill-opacity", "0.4"), v(c, "class", "svelte-43sxxs"), v(w, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), v(w, "fill", "#FF7C00"), v(w, "class", "svelte-43sxxs"), $(r, "transform", "translate(" + /*$bottom*/
214
  n[2][0] + "px, " + /*$bottom*/
215
  n[2][1] + "px)"), v(e, "viewBox", "-1200 -1200 3000 3000"), v(e, "fill", "none"), v(e, "xmlns", "http://www.w3.org/2000/svg"), v(e, "class", "svelte-43sxxs"), v(t, "class", "svelte-43sxxs"), Le(
216
  t,
@@ -220,7 +220,7 @@ function qt(n) {
220
  );
221
  },
222
  m(h, p) {
223
- pt(h, t, p), N(t, e), N(e, l), N(l, i), N(l, f), N(l, o), N(l, a), N(e, r), N(r, s), N(r, _), N(r, c), N(r, w);
224
  },
225
  p(h, [p]) {
226
  p & /*$top*/
@@ -257,10 +257,10 @@ function Ft(n, t, e) {
257
  async function _() {
258
  await s(), r || _();
259
  }
260
- async function c() {
261
  await Promise.all([o.set([125, 0]), a.set([-125, 0])]), _();
262
  }
263
- return kt(() => (c(), () => r = !0)), n.$$set = (w) => {
264
  "margin" in w && e(0, f = w.margin);
265
  }, [f, l, i, o, a];
266
  }
@@ -371,36 +371,36 @@ function It(n) {
371
  n[18] && /*show_progress*/
372
  n[6] === "full" && Ne(n)
373
  );
374
- function c(u, y) {
375
  if (
376
  /*progress*/
377
- u[7]
378
  )
379
  return Yt;
380
  if (
381
  /*queue_position*/
382
- u[2] !== null && /*queue_size*/
383
- u[3] !== void 0 && /*queue_position*/
384
- u[2] >= 0
385
  )
386
  return Xt;
387
  if (
388
  /*queue_position*/
389
- u[2] === 0
390
  )
391
  return Ht;
392
  }
393
- let w = c(n), h = w && w(n), p = (
394
  /*timer*/
395
  n[5] && je(n)
396
  );
397
  const C = [Ut, Rt], k = [];
398
- function L(u, y) {
399
  return (
400
  /*last_progress_level*/
401
- u[15] != null ? 0 : (
402
  /*show_progress*/
403
- u[6] === "full" ? 1 : -1
404
  )
405
  );
406
  }
@@ -421,41 +421,41 @@ function It(n) {
421
  n[8] === "default"
422
  );
423
  },
424
- m(u, y) {
425
- _ && _.m(u, y), g(u, t, y), g(u, e, y), h && h.m(e, null), H(e, l), p && p.m(e, null), g(u, i, y), ~f && k[f].m(u, y), g(u, a, y), F && F.m(u, y), g(u, r, y), s = !0;
426
  },
427
- p(u, y) {
428
  /*variant*/
429
- u[8] === "default" && /*show_eta_bar*/
430
- u[18] && /*show_progress*/
431
- u[6] === "full" ? _ ? _.p(u, y) : (_ = Ne(u), _.c(), _.m(t.parentNode, t)) : _ && (_.d(1), _ = null), w === (w = c(u)) && h ? h.p(u, y) : (h && h.d(1), h = w && w(u), h && (h.c(), h.m(e, l))), /*timer*/
432
- u[5] ? p ? p.p(u, y) : (p = je(u), p.c(), p.m(e, null)) : p && (p.d(1), p = null), (!s || y[0] & /*variant*/
433
  256) && V(
434
  e,
435
  "meta-text-center",
436
  /*variant*/
437
- u[8] === "center"
438
  ), (!s || y[0] & /*variant*/
439
  256) && V(
440
  e,
441
  "meta-text",
442
  /*variant*/
443
- u[8] === "default"
444
  );
445
  let m = f;
446
- f = L(u), f === m ? ~f && k[f].p(u, y) : (o && (We(), R(k[m], 1, 1, () => {
447
  k[m] = null;
448
- }), Ke()), ~f ? (o = k[f], o ? o.p(u, y) : (o = k[f] = C[f](u), o.c()), O(o, 1), o.m(a.parentNode, a)) : o = null), /*timer*/
449
- u[5] ? F && (F.d(1), F = null) : F ? F.p(u, y) : (F = Ie(u), F.c(), F.m(r.parentNode, r));
450
  },
451
- i(u) {
452
  s || (O(o), s = !0);
453
  },
454
- o(u) {
455
  R(o), s = !1;
456
  },
457
- d(u) {
458
- u && (b(t), b(e), b(i), b(a), b(r)), _ && _.d(u), h && h.d(), p && p.d(), ~f && k[f].d(u), F && F.d(u);
459
  }
460
  };
461
  }
@@ -569,7 +569,7 @@ function ze(n) {
569
  /*p*/
570
  n[38].unit + ""
571
  ), l, i, f = " ", o;
572
- function a(_, c) {
573
  return (
574
  /*p*/
575
  _[38].length != null ? Ot : Gt
@@ -580,11 +580,11 @@ function ze(n) {
580
  c() {
581
  s.c(), t = j(), l = q(e), i = q(" | "), o = q(f);
582
  },
583
- m(_, c) {
584
- s.m(_, c), g(_, t, c), g(_, l, c), g(_, i, c), g(_, o, c);
585
  },
586
- p(_, c) {
587
- r === (r = a(_)) && s ? s.p(_, c) : (s.d(1), s = r(_), s && (s.c(), s.m(t.parentNode, t))), c[0] & /*progress*/
588
  128 && e !== (e = /*p*/
589
  _[38].unit + "") && S(l, e);
590
  },
@@ -1026,9 +1026,9 @@ function Kt(n) {
1026
  g(s, t, _), ~e && a[e].m(t, null), n[31](t), f = !0;
1027
  },
1028
  p(s, _) {
1029
- let c = e;
1030
- e = r(s), e === c ? ~e && a[e].p(s, _) : (l && (We(), R(a[c], 1, 1, () => {
1031
- a[c] = null;
1032
  }), Ke()), ~e ? (l = a[e], l ? l.p(s, _) : (l = a[e] = o[e](s), l.c()), O(l, 1), l.m(t, null)) : l = null), (!f || _[0] & /*variant, show_progress*/
1033
  320 && i !== (i = "wrap " + /*variant*/
1034
  s[8] + " " + /*show_progress*/
@@ -1101,7 +1101,7 @@ async function Qt(n, t = !0) {
1101
  }
1102
  }
1103
  function Wt(n, t, e) {
1104
- let l, { $$slots: i = {}, $$scope: f } = t, { i18n: o } = t, { eta: a = null } = t, { queue: r = !1 } = t, { queue_position: s } = t, { queue_size: _ } = t, { status: c } = t, { scroll_to_output: w = !1 } = t, { timer: h = !0 } = t, { show_progress: p = "full" } = t, { message: C = null } = t, { progress: k = null } = t, { variant: L = "default" } = t, { loading_text: F = "Loading..." } = t, { absolute: u = !0 } = t, { translucent: y = !1 } = t, { border: m = !1 } = t, { autoscroll: ne } = t, J, K = !1, W = 0, E = 0, ie = null, de = 0, I = null, Q, Z = null, me = !0;
1105
  const et = () => {
1106
  e(25, W = performance.now()), e(26, E = 0), K = !0, be();
1107
  };
@@ -1128,7 +1128,7 @@ function Wt(n, t, e) {
1128
  });
1129
  }
1130
  return n.$$set = (d) => {
1131
- "i18n" in d && e(1, o = d.i18n), "eta" in d && e(0, a = d.eta), "queue" in d && e(21, r = d.queue), "queue_position" in d && e(2, s = d.queue_position), "queue_size" in d && e(3, _ = d.queue_size), "status" in d && e(4, c = d.status), "scroll_to_output" in d && e(22, w = d.scroll_to_output), "timer" in d && e(5, h = d.timer), "show_progress" in d && e(6, p = d.show_progress), "message" in d && e(23, C = d.message), "progress" in d && e(7, k = d.progress), "variant" in d && e(8, L = d.variant), "loading_text" in d && e(9, F = d.loading_text), "absolute" in d && e(10, u = d.absolute), "translucent" in d && e(11, y = d.translucent), "border" in d && e(12, m = d.border), "autoscroll" in d && e(24, ne = d.autoscroll), "$$scope" in d && e(28, f = d.$$scope);
1132
  }, n.$$.update = () => {
1133
  n.$$.dirty[0] & /*eta, old_eta, queue, timer_start*/
1134
  169869313 && (a === null ? e(0, a = ie) : r && e(0, a = (performance.now() - W) / 1e3 + a), a != null && (e(19, he = a.toFixed(1)), e(27, ie = a))), n.$$.dirty[0] & /*eta, timer_diff*/
@@ -1140,8 +1140,8 @@ function Wt(n, t, e) {
1140
  if (d.progress != null)
1141
  return d.progress;
1142
  })) : e(14, I = null), I ? (e(15, Q = I[I.length - 1]), Z && (Q === 0 ? e(16, Z.style.transition = "0", Z) : e(16, Z.style.transition = "150ms", Z))) : e(15, Q = void 0)), n.$$.dirty[0] & /*status*/
1143
- 16 && (c === "pending" ? et() : ge()), n.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
1144
- 20979728 && J && w && (c === "pending" || c === "complete") && Qt(J, ne), n.$$.dirty[0] & /*status, message*/
1145
  8388624, n.$$.dirty[0] & /*timer_diff*/
1146
  67108864 && e(20, l = E.toFixed(1));
1147
  }, [
@@ -1149,13 +1149,13 @@ function Wt(n, t, e) {
1149
  o,
1150
  s,
1151
  _,
1152
- c,
1153
  h,
1154
  p,
1155
  k,
1156
  L,
1157
  F,
1158
- u,
1159
  y,
1160
  m,
1161
  J,
@@ -1230,7 +1230,7 @@ const {
1230
  transition_out: $e,
1231
  update_slot_base: _l
1232
  } = window.__gradio__svelte__internal;
1233
- function ul(n) {
1234
  let t, e, l;
1235
  const i = (
1236
  /*#slots*/
@@ -1404,10 +1404,10 @@ function ul(n) {
1404
  }
1405
  };
1406
  }
1407
- function cl(n) {
1408
  let t, e = (
1409
  /*tag*/
1410
- n[14] && ul(n)
1411
  );
1412
  return {
1413
  c() {
@@ -1432,9 +1432,9 @@ function cl(n) {
1432
  };
1433
  }
1434
  function dl(n, t, e) {
1435
- let { $$slots: l = {}, $$scope: i } = t, { height: f = void 0 } = t, { width: o = void 0 } = t, { elem_id: a = "" } = t, { elem_classes: r = [] } = t, { variant: s = "solid" } = t, { border_mode: _ = "base" } = t, { padding: c = !0 } = t, { type: w = "normal" } = t, { test_id: h = void 0 } = t, { explicit_call: p = !1 } = t, { container: C = !0 } = t, { visible: k = !0 } = t, { allow_overflow: L = !0 } = t, { scale: F = null } = t, { min_width: u = 0 } = t, y = w === "fieldset" ? "fieldset" : "div";
1436
  return n.$$set = (m) => {
1437
- "height" in m && e(0, f = m.height), "width" in m && e(1, o = m.width), "elem_id" in m && e(2, a = m.elem_id), "elem_classes" in m && e(3, r = m.elem_classes), "variant" in m && e(4, s = m.variant), "border_mode" in m && e(5, _ = m.border_mode), "padding" in m && e(6, c = m.padding), "type" in m && e(15, w = m.type), "test_id" in m && e(7, h = m.test_id), "explicit_call" in m && e(8, p = m.explicit_call), "container" in m && e(9, C = m.container), "visible" in m && e(10, k = m.visible), "allow_overflow" in m && e(11, L = m.allow_overflow), "scale" in m && e(12, F = m.scale), "min_width" in m && e(13, u = m.min_width), "$$scope" in m && e(16, i = m.$$scope);
1438
  }, [
1439
  f,
1440
  o,
@@ -1442,14 +1442,14 @@ function dl(n, t, e) {
1442
  r,
1443
  s,
1444
  _,
1445
- c,
1446
  h,
1447
  p,
1448
  C,
1449
  k,
1450
  L,
1451
  F,
1452
- u,
1453
  y,
1454
  w,
1455
  i,
@@ -1458,7 +1458,7 @@ function dl(n, t, e) {
1458
  }
1459
  class ml extends $t {
1460
  constructor(t) {
1461
- super(), ol(this, t, dl, cl, rl, {
1462
  height: 0,
1463
  width: 1,
1464
  elem_id: 2,
@@ -1807,8 +1807,8 @@ const {
1807
  safe_not_equal: ql,
1808
  space: Fl,
1809
  toggle_class: Oe,
1810
- transition_in: ue,
1811
- transition_out: ce
1812
  } = window.__gradio__svelte__internal;
1813
  function Ll(n) {
1814
  var r;
@@ -1829,7 +1829,7 @@ function Ll(n) {
1829
  let a = {};
1830
  for (let s = 0; s < o.length; s += 1)
1831
  a = hl(a, o[s]);
1832
- return t = new xt({ props: a }), i = new ct({
1833
  props: {
1834
  min_height: (
1835
  /*loading_status*/
@@ -1868,7 +1868,7 @@ function Ll(n) {
1868
  },
1869
  p(s, _) {
1870
  var h, p;
1871
- const c = _ & /*gradio, loading_status*/
1872
  48 ? yl(o, [
1873
  _ & /*gradio*/
1874
  32 && { autoscroll: (
@@ -1887,7 +1887,7 @@ function Ll(n) {
1887
  ),
1888
  o[3]
1889
  ]) : {};
1890
- t.$set(c);
1891
  const w = {};
1892
  _ & /*loading_status*/
1893
  16 && (w.min_height = /*loading_status*/
@@ -1907,10 +1907,10 @@ function Ll(n) {
1907
  );
1908
  },
1909
  i(s) {
1910
- f || (ue(t.$$.fragment, s), ue(i.$$.fragment, s), f = !0);
1911
  },
1912
  o(s) {
1913
- ce(t.$$.fragment, s), ce(i.$$.fragment, s), f = !1;
1914
  },
1915
  d(s) {
1916
  s && (Ye(e), Ye(l)), re(t, s), re(i);
@@ -1956,10 +1956,10 @@ function Cl(n) {
1956
  318 && (f.$$scope = { dirty: i, ctx: l }), t.$set(f);
1957
  },
1958
  i(l) {
1959
- e || (ue(t.$$.fragment, l), e = !0);
1960
  },
1961
  o(l) {
1962
- ce(t.$$.fragment, l), e = !1;
1963
  },
1964
  d(l) {
1965
  re(t, l);
@@ -1969,8 +1969,8 @@ function Cl(n) {
1969
  function Ml(n, t, e) {
1970
  let { label: l } = t, { elem_id: i = "" } = t, { elem_classes: f = [] } = t, { visible: o = !0 } = t, { value: a = "" } = t, { loading_status: r } = t, { gradio: s } = t;
1971
  const _ = () => s.dispatch("change");
1972
- return n.$$set = (c) => {
1973
- "label" in c && e(6, l = c.label), "elem_id" in c && e(0, i = c.elem_id), "elem_classes" in c && e(1, f = c.elem_classes), "visible" in c && e(2, o = c.visible), "value" in c && e(3, a = c.value), "loading_status" in c && e(4, r = c.loading_status), "gradio" in c && e(5, s = c.gradio);
1974
  }, n.$$.update = () => {
1975
  n.$$.dirty & /*label, gradio*/
1976
  96 && s.dispatch("change");
 
19
  "srcdoc",
20
  /*value*/
21
  n[1]
22
+ ), B(e, "allow", "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"), e.allowFullscreen = !0, B(t, "class", l = "prose " + /*elem_classes*/
23
  n[0].join(" ") + " svelte-2qygph"), x(
24
  t,
25
  "min",
 
57
  }
58
  };
59
  }
60
+ function ct(n, t, e) {
61
  let { elem_classes: l = [] } = t, { value: i } = t, { visible: f = !0 } = t, { min_height: o = !1 } = t;
62
  const a = rt();
63
  return n.$$set = (r) => {
 
67
  2 && a("change");
68
  }, [l, i, f, o];
69
  }
70
+ class ut extends nt {
71
  constructor(t) {
72
+ super(), ft(this, t, ct, _t, at, {
73
  elem_classes: 0,
74
  value: 1,
75
  visible: 2,
 
158
  }
159
  function ke(n, t = {}) {
160
  const e = bt(n), { stiffness: l = 0.15, damping: i = 0.8, precision: f = 0.01 } = t;
161
+ let o, a, r, s = n, _ = n, u = 1, w = 0, h = !1;
162
  function p(k, L = {}) {
163
  _ = k;
164
  const F = r = {};
165
+ return n == null || L.hard || C.stiffness >= 1 && C.damping >= 1 ? (h = !0, o = pe(), s = k, e.set(n = _), Promise.resolve()) : (L.soft && (w = 1 / ((L.soft === !0 ? 0.5 : +L.soft) * 60), u = 0), a || (o = pe(), h = !1, a = mt((c) => {
166
  if (h)
167
  return h = !1, a = null, !1;
168
+ u = Math.min(u + w, 1);
169
  const y = {
170
+ inv_mass: u,
171
  opts: C,
172
  settled: !0,
173
+ dt: (c - o) * 60 / 1e3
174
  }, m = fe(y, s, n, _);
175
+ return o = c, s = n, e.set(n = m), y.settled && (a = null), !y.settled;
176
+ })), new Promise((c) => {
177
  a.promise.then(() => {
178
+ F === r && c();
179
  });
180
  }));
181
  }
 
205
  toggle_class: Le
206
  } = window.__gradio__svelte__internal, { onMount: kt } = window.__gradio__svelte__internal;
207
  function qt(n) {
208
+ let t, e, l, i, f, o, a, r, s, _, u, w;
209
  return {
210
  c() {
211
+ t = wt("div"), e = z("svg"), l = z("g"), i = z("path"), f = z("path"), o = z("path"), a = z("path"), r = z("g"), s = z("path"), _ = z("path"), u = z("path"), w = z("path"), v(i, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z"), v(i, "fill", "#FF7C00"), v(i, "fill-opacity", "0.4"), v(i, "class", "svelte-43sxxs"), v(f, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z"), v(f, "fill", "#FF7C00"), v(f, "class", "svelte-43sxxs"), v(o, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z"), v(o, "fill", "#FF7C00"), v(o, "fill-opacity", "0.4"), v(o, "class", "svelte-43sxxs"), v(a, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z"), v(a, "fill", "#FF7C00"), v(a, "class", "svelte-43sxxs"), $(l, "transform", "translate(" + /*$top*/
212
  n[1][0] + "px, " + /*$top*/
213
+ n[1][1] + "px)"), v(s, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z"), v(s, "fill", "#FF7C00"), v(s, "fill-opacity", "0.4"), v(s, "class", "svelte-43sxxs"), v(_, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z"), v(_, "fill", "#FF7C00"), v(_, "class", "svelte-43sxxs"), v(u, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z"), v(u, "fill", "#FF7C00"), v(u, "fill-opacity", "0.4"), v(u, "class", "svelte-43sxxs"), v(w, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z"), v(w, "fill", "#FF7C00"), v(w, "class", "svelte-43sxxs"), $(r, "transform", "translate(" + /*$bottom*/
214
  n[2][0] + "px, " + /*$bottom*/
215
  n[2][1] + "px)"), v(e, "viewBox", "-1200 -1200 3000 3000"), v(e, "fill", "none"), v(e, "xmlns", "http://www.w3.org/2000/svg"), v(e, "class", "svelte-43sxxs"), v(t, "class", "svelte-43sxxs"), Le(
216
  t,
 
220
  );
221
  },
222
  m(h, p) {
223
+ pt(h, t, p), N(t, e), N(e, l), N(l, i), N(l, f), N(l, o), N(l, a), N(e, r), N(r, s), N(r, _), N(r, u), N(r, w);
224
  },
225
  p(h, [p]) {
226
  p & /*$top*/
 
257
  async function _() {
258
  await s(), r || _();
259
  }
260
+ async function u() {
261
  await Promise.all([o.set([125, 0]), a.set([-125, 0])]), _();
262
  }
263
+ return kt(() => (u(), () => r = !0)), n.$$set = (w) => {
264
  "margin" in w && e(0, f = w.margin);
265
  }, [f, l, i, o, a];
266
  }
 
371
  n[18] && /*show_progress*/
372
  n[6] === "full" && Ne(n)
373
  );
374
+ function u(c, y) {
375
  if (
376
  /*progress*/
377
+ c[7]
378
  )
379
  return Yt;
380
  if (
381
  /*queue_position*/
382
+ c[2] !== null && /*queue_size*/
383
+ c[3] !== void 0 && /*queue_position*/
384
+ c[2] >= 0
385
  )
386
  return Xt;
387
  if (
388
  /*queue_position*/
389
+ c[2] === 0
390
  )
391
  return Ht;
392
  }
393
+ let w = u(n), h = w && w(n), p = (
394
  /*timer*/
395
  n[5] && je(n)
396
  );
397
  const C = [Ut, Rt], k = [];
398
+ function L(c, y) {
399
  return (
400
  /*last_progress_level*/
401
+ c[15] != null ? 0 : (
402
  /*show_progress*/
403
+ c[6] === "full" ? 1 : -1
404
  )
405
  );
406
  }
 
421
  n[8] === "default"
422
  );
423
  },
424
+ m(c, y) {
425
+ _ && _.m(c, y), g(c, t, y), g(c, e, y), h && h.m(e, null), H(e, l), p && p.m(e, null), g(c, i, y), ~f && k[f].m(c, y), g(c, a, y), F && F.m(c, y), g(c, r, y), s = !0;
426
  },
427
+ p(c, y) {
428
  /*variant*/
429
+ c[8] === "default" && /*show_eta_bar*/
430
+ c[18] && /*show_progress*/
431
+ c[6] === "full" ? _ ? _.p(c, y) : (_ = Ne(c), _.c(), _.m(t.parentNode, t)) : _ && (_.d(1), _ = null), w === (w = u(c)) && h ? h.p(c, y) : (h && h.d(1), h = w && w(c), h && (h.c(), h.m(e, l))), /*timer*/
432
+ c[5] ? p ? p.p(c, y) : (p = je(c), p.c(), p.m(e, null)) : p && (p.d(1), p = null), (!s || y[0] & /*variant*/
433
  256) && V(
434
  e,
435
  "meta-text-center",
436
  /*variant*/
437
+ c[8] === "center"
438
  ), (!s || y[0] & /*variant*/
439
  256) && V(
440
  e,
441
  "meta-text",
442
  /*variant*/
443
+ c[8] === "default"
444
  );
445
  let m = f;
446
+ f = L(c), f === m ? ~f && k[f].p(c, y) : (o && (We(), R(k[m], 1, 1, () => {
447
  k[m] = null;
448
+ }), Ke()), ~f ? (o = k[f], o ? o.p(c, y) : (o = k[f] = C[f](c), o.c()), O(o, 1), o.m(a.parentNode, a)) : o = null), /*timer*/
449
+ c[5] ? F && (F.d(1), F = null) : F ? F.p(c, y) : (F = Ie(c), F.c(), F.m(r.parentNode, r));
450
  },
451
+ i(c) {
452
  s || (O(o), s = !0);
453
  },
454
+ o(c) {
455
  R(o), s = !1;
456
  },
457
+ d(c) {
458
+ c && (b(t), b(e), b(i), b(a), b(r)), _ && _.d(c), h && h.d(), p && p.d(), ~f && k[f].d(c), F && F.d(c);
459
  }
460
  };
461
  }
 
569
  /*p*/
570
  n[38].unit + ""
571
  ), l, i, f = " ", o;
572
+ function a(_, u) {
573
  return (
574
  /*p*/
575
  _[38].length != null ? Ot : Gt
 
580
  c() {
581
  s.c(), t = j(), l = q(e), i = q(" | "), o = q(f);
582
  },
583
+ m(_, u) {
584
+ s.m(_, u), g(_, t, u), g(_, l, u), g(_, i, u), g(_, o, u);
585
  },
586
+ p(_, u) {
587
+ r === (r = a(_)) && s ? s.p(_, u) : (s.d(1), s = r(_), s && (s.c(), s.m(t.parentNode, t))), u[0] & /*progress*/
588
  128 && e !== (e = /*p*/
589
  _[38].unit + "") && S(l, e);
590
  },
 
1026
  g(s, t, _), ~e && a[e].m(t, null), n[31](t), f = !0;
1027
  },
1028
  p(s, _) {
1029
+ let u = e;
1030
+ e = r(s), e === u ? ~e && a[e].p(s, _) : (l && (We(), R(a[u], 1, 1, () => {
1031
+ a[u] = null;
1032
  }), Ke()), ~e ? (l = a[e], l ? l.p(s, _) : (l = a[e] = o[e](s), l.c()), O(l, 1), l.m(t, null)) : l = null), (!f || _[0] & /*variant, show_progress*/
1033
  320 && i !== (i = "wrap " + /*variant*/
1034
  s[8] + " " + /*show_progress*/
 
1101
  }
1102
  }
1103
  function Wt(n, t, e) {
1104
+ let l, { $$slots: i = {}, $$scope: f } = t, { i18n: o } = t, { eta: a = null } = t, { queue: r = !1 } = t, { queue_position: s } = t, { queue_size: _ } = t, { status: u } = t, { scroll_to_output: w = !1 } = t, { timer: h = !0 } = t, { show_progress: p = "full" } = t, { message: C = null } = t, { progress: k = null } = t, { variant: L = "default" } = t, { loading_text: F = "Loading..." } = t, { absolute: c = !0 } = t, { translucent: y = !1 } = t, { border: m = !1 } = t, { autoscroll: ne } = t, J, K = !1, W = 0, E = 0, ie = null, de = 0, I = null, Q, Z = null, me = !0;
1105
  const et = () => {
1106
  e(25, W = performance.now()), e(26, E = 0), K = !0, be();
1107
  };
 
1128
  });
1129
  }
1130
  return n.$$set = (d) => {
1131
+ "i18n" in d && e(1, o = d.i18n), "eta" in d && e(0, a = d.eta), "queue" in d && e(21, r = d.queue), "queue_position" in d && e(2, s = d.queue_position), "queue_size" in d && e(3, _ = d.queue_size), "status" in d && e(4, u = d.status), "scroll_to_output" in d && e(22, w = d.scroll_to_output), "timer" in d && e(5, h = d.timer), "show_progress" in d && e(6, p = d.show_progress), "message" in d && e(23, C = d.message), "progress" in d && e(7, k = d.progress), "variant" in d && e(8, L = d.variant), "loading_text" in d && e(9, F = d.loading_text), "absolute" in d && e(10, c = d.absolute), "translucent" in d && e(11, y = d.translucent), "border" in d && e(12, m = d.border), "autoscroll" in d && e(24, ne = d.autoscroll), "$$scope" in d && e(28, f = d.$$scope);
1132
  }, n.$$.update = () => {
1133
  n.$$.dirty[0] & /*eta, old_eta, queue, timer_start*/
1134
  169869313 && (a === null ? e(0, a = ie) : r && e(0, a = (performance.now() - W) / 1e3 + a), a != null && (e(19, he = a.toFixed(1)), e(27, ie = a))), n.$$.dirty[0] & /*eta, timer_diff*/
 
1140
  if (d.progress != null)
1141
  return d.progress;
1142
  })) : e(14, I = null), I ? (e(15, Q = I[I.length - 1]), Z && (Q === 0 ? e(16, Z.style.transition = "0", Z) : e(16, Z.style.transition = "150ms", Z))) : e(15, Q = void 0)), n.$$.dirty[0] & /*status*/
1143
+ 16 && (u === "pending" ? et() : ge()), n.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
1144
+ 20979728 && J && w && (u === "pending" || u === "complete") && Qt(J, ne), n.$$.dirty[0] & /*status, message*/
1145
  8388624, n.$$.dirty[0] & /*timer_diff*/
1146
  67108864 && e(20, l = E.toFixed(1));
1147
  }, [
 
1149
  o,
1150
  s,
1151
  _,
1152
+ u,
1153
  h,
1154
  p,
1155
  k,
1156
  L,
1157
  F,
1158
+ c,
1159
  y,
1160
  m,
1161
  J,
 
1230
  transition_out: $e,
1231
  update_slot_base: _l
1232
  } = window.__gradio__svelte__internal;
1233
+ function cl(n) {
1234
  let t, e, l;
1235
  const i = (
1236
  /*#slots*/
 
1404
  }
1405
  };
1406
  }
1407
+ function ul(n) {
1408
  let t, e = (
1409
  /*tag*/
1410
+ n[14] && cl(n)
1411
  );
1412
  return {
1413
  c() {
 
1432
  };
1433
  }
1434
  function dl(n, t, e) {
1435
+ let { $$slots: l = {}, $$scope: i } = t, { height: f = void 0 } = t, { width: o = void 0 } = t, { elem_id: a = "" } = t, { elem_classes: r = [] } = t, { variant: s = "solid" } = t, { border_mode: _ = "base" } = t, { padding: u = !0 } = t, { type: w = "normal" } = t, { test_id: h = void 0 } = t, { explicit_call: p = !1 } = t, { container: C = !0 } = t, { visible: k = !0 } = t, { allow_overflow: L = !0 } = t, { scale: F = null } = t, { min_width: c = 0 } = t, y = w === "fieldset" ? "fieldset" : "div";
1436
  return n.$$set = (m) => {
1437
+ "height" in m && e(0, f = m.height), "width" in m && e(1, o = m.width), "elem_id" in m && e(2, a = m.elem_id), "elem_classes" in m && e(3, r = m.elem_classes), "variant" in m && e(4, s = m.variant), "border_mode" in m && e(5, _ = m.border_mode), "padding" in m && e(6, u = m.padding), "type" in m && e(15, w = m.type), "test_id" in m && e(7, h = m.test_id), "explicit_call" in m && e(8, p = m.explicit_call), "container" in m && e(9, C = m.container), "visible" in m && e(10, k = m.visible), "allow_overflow" in m && e(11, L = m.allow_overflow), "scale" in m && e(12, F = m.scale), "min_width" in m && e(13, c = m.min_width), "$$scope" in m && e(16, i = m.$$scope);
1438
  }, [
1439
  f,
1440
  o,
 
1442
  r,
1443
  s,
1444
  _,
1445
+ u,
1446
  h,
1447
  p,
1448
  C,
1449
  k,
1450
  L,
1451
  F,
1452
+ c,
1453
  y,
1454
  w,
1455
  i,
 
1458
  }
1459
  class ml extends $t {
1460
  constructor(t) {
1461
+ super(), ol(this, t, dl, ul, rl, {
1462
  height: 0,
1463
  width: 1,
1464
  elem_id: 2,
 
1807
  safe_not_equal: ql,
1808
  space: Fl,
1809
  toggle_class: Oe,
1810
+ transition_in: ce,
1811
+ transition_out: ue
1812
  } = window.__gradio__svelte__internal;
1813
  function Ll(n) {
1814
  var r;
 
1829
  let a = {};
1830
  for (let s = 0; s < o.length; s += 1)
1831
  a = hl(a, o[s]);
1832
+ return t = new xt({ props: a }), i = new ut({
1833
  props: {
1834
  min_height: (
1835
  /*loading_status*/
 
1868
  },
1869
  p(s, _) {
1870
  var h, p;
1871
+ const u = _ & /*gradio, loading_status*/
1872
  48 ? yl(o, [
1873
  _ & /*gradio*/
1874
  32 && { autoscroll: (
 
1887
  ),
1888
  o[3]
1889
  ]) : {};
1890
+ t.$set(u);
1891
  const w = {};
1892
  _ & /*loading_status*/
1893
  16 && (w.min_height = /*loading_status*/
 
1907
  );
1908
  },
1909
  i(s) {
1910
+ f || (ce(t.$$.fragment, s), ce(i.$$.fragment, s), f = !0);
1911
  },
1912
  o(s) {
1913
+ ue(t.$$.fragment, s), ue(i.$$.fragment, s), f = !1;
1914
  },
1915
  d(s) {
1916
  s && (Ye(e), Ye(l)), re(t, s), re(i);
 
1956
  318 && (f.$$scope = { dirty: i, ctx: l }), t.$set(f);
1957
  },
1958
  i(l) {
1959
+ e || (ce(t.$$.fragment, l), e = !0);
1960
  },
1961
  o(l) {
1962
+ ue(t.$$.fragment, l), e = !1;
1963
  },
1964
  d(l) {
1965
  re(t, l);
 
1969
  function Ml(n, t, e) {
1970
  let { label: l } = t, { elem_id: i = "" } = t, { elem_classes: f = [] } = t, { visible: o = !0 } = t, { value: a = "" } = t, { loading_status: r } = t, { gradio: s } = t;
1971
  const _ = () => s.dispatch("change");
1972
+ return n.$$set = (u) => {
1973
+ "label" in u && e(6, l = u.label), "elem_id" in u && e(0, i = u.elem_id), "elem_classes" in u && e(1, f = u.elem_classes), "visible" in u && e(2, o = u.visible), "value" in u && e(3, a = u.value), "loading_status" in u && e(4, r = u.loading_status), "gradio" in u && e(5, s = u.gradio);
1974
  }, n.$$.update = () => {
1975
  n.$$.dirty & /*label, gradio*/
1976
  96 && s.dispatch("change");
components/iframe/backend/gradio_iframe/templates/example/index.js CHANGED
@@ -1,78 +1,87 @@
1
  const {
2
- SvelteComponent: c,
3
- attr: u,
4
- detach: r,
 
5
  element: o,
6
- init: d,
7
- insert: g,
8
  noop: _,
9
  safe_not_equal: v,
10
- toggle_class: s
11
  } = window.__gradio__svelte__internal;
12
  function y(n) {
13
- let e;
14
  return {
15
  c() {
16
- e = o("div"), u(e, "class", "prose svelte-180qqaf"), s(
 
 
 
 
 
17
  e,
18
  "table",
19
  /*type*/
20
  n[1] === "table"
21
- ), s(
22
  e,
23
  "gallery",
24
  /*type*/
25
  n[1] === "gallery"
26
- ), s(
27
  e,
28
  "selected",
29
  /*selected*/
30
  n[2]
31
  );
32
  },
33
- m(l, t) {
34
- g(l, e, t), e.innerHTML = /*value*/
35
- n[0];
36
  },
37
- p(l, [t]) {
38
- t & /*value*/
39
- 1 && (e.innerHTML = /*value*/
40
- l[0]), t & /*type*/
41
- 2 && s(
 
 
 
 
42
  e,
43
  "table",
44
  /*type*/
45
- l[1] === "table"
46
- ), t & /*type*/
47
- 2 && s(
48
  e,
49
  "gallery",
50
  /*type*/
51
- l[1] === "gallery"
52
- ), t & /*selected*/
53
- 4 && s(
54
  e,
55
  "selected",
56
  /*selected*/
57
- l[2]
58
  );
59
  },
60
  i: _,
61
  o: _,
62
- d(l) {
63
- l && r(e);
64
  }
65
  };
66
  }
67
- function m(n, e, l) {
68
- let { value: t } = e, { type: i } = e, { selected: f = !1 } = e;
69
- return n.$$set = (a) => {
70
- "value" in a && l(0, t = a.value), "type" in a && l(1, i = a.type), "selected" in a && l(2, f = a.selected);
71
- }, [t, i, f];
72
  }
73
- class b extends c {
74
  constructor(e) {
75
- super(), d(this, e, m, y, v, { value: 0, type: 1, selected: 2 });
76
  }
77
  }
78
  export {
 
1
  const {
2
+ SvelteComponent: r,
3
+ append: d,
4
+ attr: s,
5
+ detach: u,
6
  element: o,
7
+ init: g,
8
+ insert: m,
9
  noop: _,
10
  safe_not_equal: v,
11
+ toggle_class: c
12
  } = window.__gradio__svelte__internal;
13
  function y(n) {
14
+ let e, l;
15
  return {
16
  c() {
17
+ e = o("div"), l = o("iframe"), s(l, "title", "iframe component"), s(l, "width", "100%"), s(l, "height", "100%"), s(
18
+ l,
19
+ "srcdoc",
20
+ /*value*/
21
+ n[0]
22
+ ), s(l, "allow", ""), s(e, "class", "prose svelte-180qqaf"), c(
23
  e,
24
  "table",
25
  /*type*/
26
  n[1] === "table"
27
+ ), c(
28
  e,
29
  "gallery",
30
  /*type*/
31
  n[1] === "gallery"
32
+ ), c(
33
  e,
34
  "selected",
35
  /*selected*/
36
  n[2]
37
  );
38
  },
39
+ m(t, a) {
40
+ m(t, e, a), d(e, l);
 
41
  },
42
+ p(t, [a]) {
43
+ a & /*value*/
44
+ 1 && s(
45
+ l,
46
+ "srcdoc",
47
+ /*value*/
48
+ t[0]
49
+ ), a & /*type*/
50
+ 2 && c(
51
  e,
52
  "table",
53
  /*type*/
54
+ t[1] === "table"
55
+ ), a & /*type*/
56
+ 2 && c(
57
  e,
58
  "gallery",
59
  /*type*/
60
+ t[1] === "gallery"
61
+ ), a & /*selected*/
62
+ 4 && c(
63
  e,
64
  "selected",
65
  /*selected*/
66
+ t[2]
67
  );
68
  },
69
  i: _,
70
  o: _,
71
+ d(t) {
72
+ t && u(e);
73
  }
74
  };
75
  }
76
+ function h(n, e, l) {
77
+ let { value: t } = e, { type: a } = e, { selected: f = !1 } = e;
78
+ return n.$$set = (i) => {
79
+ "value" in i && l(0, t = i.value), "type" in i && l(1, a = i.type), "selected" in i && l(2, f = i.selected);
80
+ }, [t, a, f];
81
  }
82
+ class b extends r {
83
  constructor(e) {
84
+ super(), g(this, e, h, y, v, { value: 0, type: 1, selected: 2 });
85
  }
86
  }
87
  export {
components/iframe/demo/app.py CHANGED
@@ -1,14 +1,14 @@
1
 
2
  import gradio as gr
3
- from gradio_iframe import iframe
4
 
5
 
6
- example = iframe().example_inputs()
7
 
8
  with gr.Blocks() as demo:
9
  with gr.Row():
10
- iframe(label="Blank"), # blank component
11
- iframe(value=example, label="Populated"), # populated component
12
 
13
 
14
  demo.launch()
 
1
 
2
  import gradio as gr
3
+ from gradio_iframe import iFrame
4
 
5
 
6
+ example = iFrame().example_inputs()
7
 
8
  with gr.Blocks() as demo:
9
  with gr.Row():
10
+ iFrame(label="Blank"), # blank component
11
+ iFrame(value=example, label="Populated"), # populated component
12
 
13
 
14
  demo.launch()
components/iframe/dist/gradio_iframe-0.0.1-py3-none-any.whl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:89a65095990947350e91bb27538852ce7f9a856bf20d94ddf5461e5e8bf2e0fe
3
- size 21918
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:351bbf23910152c10119a0d1cb8c84f23d7e4c90c07dcee03631399503a41de8
3
+ size 21979
components/iframe/dist/gradio_iframe-0.0.1.tar.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6ac7a0939e1b5369c1a92a7d162b42b14745715d13b6a7ba4aba421f038a4119
3
- size 29819
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:519057fefe48fb075a818a5a7f44b1a35e5b907606f5038480e618a3e43f75cf
3
+ size 29934
components/iframe/dist/gradio_iframe-0.0.2-py3-none-any.whl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5570781e268d26cb6caa8e35f7d3e1d52c936c9707d4445b2584397ed128eed7
3
- size 22030
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aaa68bb5d7a8487586fd80e30306a4a3610dbc685e52026b448fa4de92e18b3f
3
+ size 22702
components/iframe/dist/gradio_iframe-0.0.2.tar.gz CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:86beaaa1599a7f6bda48c94b8e955bcb9e7c0659f99a5a95fe11bd5b04acfbe9
3
- size 29965
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ece16fd992e2a16605c62fa918f670ff0bf49bf9b94d0b97299595303dc0584b
3
+ size 30837
components/iframe/dist/gradio_iframe-0.0.3-py3-none-any.whl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1475685f2e4fbf58ff22448fca8fef9150e0f26633f0e94a4edf40eaa82cb12
3
+ size 22716
components/iframe/dist/gradio_iframe-0.0.3.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:abd2babf1c9fdb11117e9ba87bdb189ee573bbacdf0b4e6f707aa92b6620036d
3
+ size 30850
components/iframe/frontend/Example.svelte CHANGED
@@ -10,7 +10,7 @@
10
  class:selected
11
  class="prose"
12
  >
13
- {@html value}
14
  </div>
15
 
16
  <style>
 
10
  class:selected
11
  class="prose"
12
  >
13
+ <iframe title="iframe component" width="100%" height="100%" srcdoc={value} allow=""></iframe>
14
  </div>
15
 
16
  <style>
components/iframe/frontend/shared/HTML.svelte CHANGED
@@ -8,7 +8,6 @@
8
  const dispatch = createEventDispatcher<{ change: undefined }>();
9
 
10
  $: value, dispatch("change");
11
-
12
  </script>
13
 
14
  <div
@@ -16,7 +15,7 @@
16
  class:min={min_height}
17
  class:hide={!visible}
18
  >
19
- <iframe title="iframe component" width="100%" height="100%" srcdoc={value} allow=""></iframe>
20
  </div>
21
 
22
  <style>
 
8
  const dispatch = createEventDispatcher<{ change: undefined }>();
9
 
10
  $: value, dispatch("change");
 
11
  </script>
12
 
13
  <div
 
15
  class:min={min_height}
16
  class:hide={!visible}
17
  >
18
+ <iframe title="iframe component" width="100%" height="100%" srcdoc={value} allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
19
  </div>
20
 
21
  <style>
components/iframe/pyproject.toml CHANGED
@@ -8,8 +8,8 @@ build-backend = "hatchling.build"
8
 
9
  [project]
10
  name = "gradio_iframe"
11
- version = "0.0.5"
12
- description = "Enhanced HTML components that display an interactive iframe element."
13
  readme = "README.md"
14
  license = "MIT"
15
  requires-python = ">=3.8"
@@ -36,7 +36,7 @@ classifiers = [
36
  dev = ["build", "twine"]
37
 
38
  [tool.hatch.build]
39
- artifacts = ["/backend/gradio_iframe/templates", "*.pyi", "backend/gradio_iframe/templates", "backend/gradio_iframe/templates", "home/lennard/.virtualenvs/thesis/lib/python3.11/site-packages/gradio_iframe/templates", "home/lennard/.virtualenvs/thesis/lib/python3.11/site-packages/gradio_iframe/templates", "home/lennard/.virtualenvs/thesis/lib/python3.11/site-packages/gradio_iframe/templates"]
40
 
41
  [tool.hatch.build.targets.wheel]
42
  packages = ["/backend/gradio_iframe"]
 
8
 
9
  [project]
10
  name = "gradio_iframe"
11
+ version = "0.0.3"
12
+ description = "Experimental empowered iFrame component based on existing HTML gradio component."
13
  readme = "README.md"
14
  license = "MIT"
15
  requires-python = ">=3.8"
 
36
  dev = ["build", "twine"]
37
 
38
  [tool.hatch.build]
39
+ artifacts = ["/backend/gradio_iframe/templates", "*.pyi", "backend/gradio_iframe/templates", "home/lennard/.virtualenvs/thesis/lib/python3.11/site-packages/gradio_iframe/templates", "backend/gradio_iframe/templates"]
40
 
41
  [tool.hatch.build.targets.wheel]
42
  packages = ["/backend/gradio_iframe"]
explanation/markup.py CHANGED
@@ -41,8 +41,6 @@ def markup_text(input_text: list, text_values: ndarray, variant: str):
41
  bucket = i
42
  marked_text.append((text, str(bucket)))
43
 
44
- print(thresholds)
45
- print(marked_text)
46
  return marked_text
47
 
48
 
 
41
  bucket = i
42
  marked_text.append((text, str(bucket)))
43
 
 
 
44
  return marked_text
45
 
46
 
main.py CHANGED
@@ -8,6 +8,7 @@ from fastapi import FastAPI
8
  import markdown
9
  import gradio as gr
10
  from uvicorn import run
 
11
 
12
  # internal imports
13
  from backend.controller import interference
@@ -59,7 +60,7 @@ with gr.Blocks(
59
  # markdown component to display the header
60
  gr.Markdown("""
61
  # Thesis Demo - AI Chat Application with GODEL
62
- ## XAI powered by SHAP and BERTVIZ
63
  ### Select between tabs below for the different views.
64
  """)
65
  # ChatBot tab used to chat with the AI chatbot
@@ -73,6 +74,8 @@ with gr.Blocks(
73
  including the selection of the model,
74
  the system prompt and the XAI method.
75
 
 
 
76
  """)
77
  # row with columns for the different settings
78
  with gr.Row(equal_height=True):
@@ -145,7 +148,7 @@ with gr.Blocks(
145
  show_label=True,
146
  )
147
  # row with columns for buttons to submit and clear content
148
- with gr.Row(elem_classes="border-"):
149
  with gr.Column(scale=1):
150
  # out of the box clear button which clearn the given components (see
151
  # documentation: https://www.gradio.app/docs/clearbutton)
@@ -185,14 +188,13 @@ with gr.Blocks(
185
  with gr.Row():
186
  gr.Markdown("""
187
  ### Get Explanations for Conversations
188
- Using your selected XAI method, you can get explanations for
189
- the conversation you had with the AI ChatBot. The explanations are
190
- based on the last message you sent to the AI ChatBot (see text)
191
  """)
192
  # row that displays the generated explanation of the model (if applicable)
193
  with gr.Row(variant="panel"):
194
  # wraps the explanation html to display it statically
195
- xai_interactive = gr.HTML(
196
  label="Static Explanation",
197
  value=(
198
  '<div style="text-align: center"><h4>No Graphic to Display'
@@ -202,7 +204,7 @@ with gr.Blocks(
202
  )
203
  # row and accordion to display an explanation plot (if applicable)
204
  with gr.Row():
205
- with gr.Accordion("Token Explanation Plot", open=False):
206
  gr.Markdown("""
207
  #### Plotted Values
208
  Values have been excluded for readability. See colorbar for value indication.
 
8
  import markdown
9
  import gradio as gr
10
  from uvicorn import run
11
+ from gradio_iframe import iFrame
12
 
13
  # internal imports
14
  from backend.controller import interference
 
60
  # markdown component to display the header
61
  gr.Markdown("""
62
  # Thesis Demo - AI Chat Application with GODEL
63
+ ## Interpretability powered by SHAP and BERTVIZ
64
  ### Select between tabs below for the different views.
65
  """)
66
  # ChatBot tab used to chat with the AI chatbot
 
74
  including the selection of the model,
75
  the system prompt and the XAI method.
76
 
77
+ **See Explanations in the accordion above the chat.**
78
+
79
  """)
80
  # row with columns for the different settings
81
  with gr.Row(equal_height=True):
 
148
  show_label=True,
149
  )
150
  # row with columns for buttons to submit and clear content
151
+ with gr.Row(elem_classes=""):
152
  with gr.Column(scale=1):
153
  # out of the box clear button which clearn the given components (see
154
  # documentation: https://www.gradio.app/docs/clearbutton)
 
188
  with gr.Row():
189
  gr.Markdown("""
190
  ### Get Explanations for Conversations
191
+ Get additional explanations for the last conversation you had with the AI ChatBot.
192
+ Depending on the selected XAI method, different explanations are available.
 
193
  """)
194
  # row that displays the generated explanation of the model (if applicable)
195
  with gr.Row(variant="panel"):
196
  # wraps the explanation html to display it statically
197
+ xai_interactive = iFrame(
198
  label="Static Explanation",
199
  value=(
200
  '<div style="text-align: center"><h4>No Graphic to Display'
 
204
  )
205
  # row and accordion to display an explanation plot (if applicable)
206
  with gr.Row():
207
+ with gr.Accordion("Token Wise Explanation Plot", open=False):
208
  gr.Markdown("""
209
  #### Plotted Values
210
  Values have been excluded for readability. See colorbar for value indication.
public/about.md CHANGED
@@ -4,13 +4,20 @@ This is a non-commercial research projects as part of a Bachelor Thesis with the
4
 
5
  This research tackles the rise of LLM based applications such a chatbots and explores the possibilities of model interpretation and explainability. The goal is to build a tool that can be used to explain the predictions of a LLM based chatbot.
6
 
 
 
 
 
 
 
 
7
  ## Implementation
8
 
9
  This project is an implementation of PartitionSHAP and BERTViz into GODEL by Microsoft - [GODEL Model](https://huggingface.co/microsoft/GODEL-v1_1-large-seq2seq) which is a generative seq2seq transformer fine-tuned for goal directed dialog. It supports context and knowledge base inputs.
10
 
11
  The UI is build with Gradio.
12
 
13
- ## Usage
14
 
15
  You can chat with the model by entering a message into the input field and pressing enter. The model will then generate a response. You can also enter a context and knowledge base by clicking on the respective buttons and entering the data into the input fields. The model will then generate a response based on the context and knowledge base.
16
 
@@ -18,7 +25,7 @@ To explore explanations, chose one of the explanations methods (HINT: The runtim
18
 
19
  ### Self Hosted
20
 
21
- You can run this application locally by cloning this repository, setting up a python environment and installing the requirements. Then run the `app.py` file or use "uvicorn main:app --reload" in the *python terminal*.
22
 
23
  For self-hosting you can use the Dockerfile to build a docker image and run it locally or directly use the provided docker image on the [GitHub page](https://github.com/lennardzuendorf/thesis-webapp/).
24
 
@@ -37,7 +44,7 @@ Please credit the original authors of this project (Lennard Zündorf) and the cr
37
  - [LinkedIn](https://www.zuendorf.me/linkd)
38
 
39
 
40
- #### University
41
  Hochschule für Technik und Wirtschaft Berlin (HTW Berlin) - University of Applied Sciences for Engineering and Economics Berlin
42
 
43
  1. Supervisor: Prof. Dr. Katarina Simbeck
 
4
 
5
  This research tackles the rise of LLM based applications such a chatbots and explores the possibilities of model interpretation and explainability. The goal is to build a tool that can be used to explain the predictions of a LLM based chatbot.
6
 
7
+ ## Links
8
+
9
+ - [GitHub Repository](https://github.com/LennardZuendorf/thesis-webapp) - The GitHub repository of this project.
10
+ - [HTW Berlin](https://www.htw-berlin.de/) - The University I have built this project for, as part of my thesis.
11
+ - [Thesis Print]() - Link to the thesis pdf (in English), containing more information about the project. And a full list of sources for this work as well as additional evaluations and fundamental information for the project.
12
+
13
+
14
  ## Implementation
15
 
16
  This project is an implementation of PartitionSHAP and BERTViz into GODEL by Microsoft - [GODEL Model](https://huggingface.co/microsoft/GODEL-v1_1-large-seq2seq) which is a generative seq2seq transformer fine-tuned for goal directed dialog. It supports context and knowledge base inputs.
17
 
18
  The UI is build with Gradio.
19
 
20
+ ### Usage
21
 
22
  You can chat with the model by entering a message into the input field and pressing enter. The model will then generate a response. You can also enter a context and knowledge base by clicking on the respective buttons and entering the data into the input fields. The model will then generate a response based on the context and knowledge base.
23
 
 
25
 
26
  ### Self Hosted
27
 
28
+ You can run this application locally by cloning this repository, setting up a python environment and installing the requirements from the requirements.txt. Then run the `app.py` file or use "uvicorn main:app --reload" in the *python terminal*.
29
 
30
  For self-hosting you can use the Dockerfile to build a docker image and run it locally or directly use the provided docker image on the [GitHub page](https://github.com/lennardzuendorf/thesis-webapp/).
31
 
 
44
  - [LinkedIn](https://www.zuendorf.me/linkd)
45
 
46
 
47
+ ### University
48
  Hochschule für Technik und Wirtschaft Berlin (HTW Berlin) - University of Applied Sciences for Engineering and Economics Berlin
49
 
50
  1. Supervisor: Prof. Dr. Katarina Simbeck
public/credits_dataprotection_license.md CHANGED
@@ -1,8 +1,3 @@
1
- # Links
2
-
3
- - [GitHub Repository](https://github.com/LennardZuendorf/thesis-webapp) - The GitHub repository of this project.
4
- - [HTW Berlin](https://www.htw-berlin.de/) - The University I have built this project for, as part of my thesis.
5
- - [Thesis Print]() - Link to the thesis pdf (in English), containing more information about the project. And a full list of sources for this work as well as additional evaluations and fundamental information for the project.
6
 
7
 
8
  # Credits
 
 
 
 
 
 
1
 
2
 
3
  # Credits
requirements.txt CHANGED
@@ -16,3 +16,4 @@ numpy
16
  matplotlib
17
  pre-commit
18
  ipython
 
 
16
  matplotlib
17
  pre-commit
18
  ipython
19
+ gradio-iframe