@gradio/core 0.25.0 → 0.27.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
1
  # @gradio/core
2
2
 
3
+ ## 0.27.0
4
+
5
+ ### Features
6
+
7
+ - [#11723](https://github.com/gradio-app/gradio/pull/11723) [`379f0c1`](https://github.com/gradio-app/gradio/commit/379f0c151943b5f269910eba4a4c7abc6145a11c) - Support MCP resources and prompts. Thanks @abidlabs!
8
+
9
+ ### Fixes
10
+
11
+ - [#11725](https://github.com/gradio-app/gradio/pull/11725) [`080f888`](https://github.com/gradio-app/gradio/commit/080f888e3b173b5b2deef5eaf9754f2a63adf1aa) - Ensure it is possible to use `@render` to generate Tabs. Thanks @aliabid94!
12
+
13
+ ### Dependency updates
14
+
15
+ - @gradio/code@0.14.15
16
+ - @gradio/statustracker@0.10.17
17
+ - @gradio/paramviewer@0.7.15
18
+ - @gradio/atoms@0.16.5
19
+ - @gradio/column@0.2.1
20
+ - @gradio/client@1.17.1
21
+ - @gradio/icons@0.13.0
22
+ - @gradio/upload@0.16.15
23
+ - @gradio/image@0.22.17
24
+ - @gradio/dropdown@0.10.2
25
+ - @gradio/textbox@0.10.20
26
+ - @gradio/button@0.5.11
27
+ - @gradio/gallery@0.15.31
28
+ - @gradio/plot@0.9.22
29
+ - @gradio/checkbox@0.4.28
30
+ - @gradio/file@0.12.28
31
+ - @gradio/video@0.15.0
32
+
33
+ ## 0.26.0
34
+
35
+ ### Features
36
+
37
+ - [#11691](https://github.com/gradio-app/gradio/pull/11691) [`2605a99`](https://github.com/gradio-app/gradio/commit/2605a99bf29bebbbb0a97cc8e0015b5bf8d8e79b) - Add .failure() event listener for error handling. Thanks @elanehan!
38
+
39
+ ### Fixes
40
+
41
+ - [#11698](https://github.com/gradio-app/gradio/pull/11698) [`fc41f09`](https://github.com/gradio-app/gradio/commit/fc41f0950b7c427abcebdc9a113148a219d8f3f6) - Fix visibility changes in gr.render. Thanks @aliabid94!
42
+
43
+ ### Dependency updates
44
+
45
+ - @gradio/code@0.14.14
46
+ - @gradio/paramviewer@0.7.14
47
+ - @gradio/statustracker@0.10.16
48
+ - @gradio/video@0.14.24
49
+ - @gradio/atoms@0.16.4
50
+ - @gradio/column@0.2.1
51
+ - @gradio/client@1.17.0
52
+ - @gradio/upload@0.16.14
53
+ - @gradio/button@0.5.10
54
+ - @gradio/gallery@0.15.30
55
+ - @gradio/plot@0.9.21
56
+ - @gradio/checkbox@0.4.27
57
+ - @gradio/textbox@0.10.19
58
+ - @gradio/dropdown@0.10.1
59
+ - @gradio/file@0.12.27
60
+ - @gradio/image@0.22.16
61
+
3
62
  ## 0.25.0
4
63
 
5
64
  ### Features
@@ -562,7 +562,7 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
562
562
  }
563
563
  if (status.stage === "complete") {
564
564
  dependencies.forEach(async (dep2) => {
565
- if (dep2.trigger_after === fn_index) {
565
+ if (dep2.trigger_after === fn_index && !dep2.trigger_only_on_failure) {
566
566
  wait_then_trigger_api_call(dep2.id, payload2.trigger_id);
567
567
  }
568
568
  });
@@ -591,7 +591,7 @@ async function trigger_api_call(dep_index, trigger_id = null, event_data = null)
591
591
  ];
592
592
  }
593
593
  dependencies.map(async (dep2) => {
594
- if (dep2.trigger_after === fn_index && !dep2.trigger_only_on_success) {
594
+ if (dep2.trigger_after === fn_index && (!dep2.trigger_only_on_success || dep2.trigger_only_on_failure)) {
595
595
  wait_then_trigger_api_call(dep2.id, payload2.trigger_id);
596
596
  }
597
597
  });
@@ -126,6 +126,7 @@ async function fetch_mcp_tools() {
126
126
  name: tool.name,
127
127
  description: tool.description || "",
128
128
  parameters: tool.inputSchema?.properties || {},
129
+ meta: tool.meta,
129
130
  expanded: false
130
131
  }));
131
132
  selected_tools = new Set(tools.map((tool) => tool.name));
@@ -17,6 +17,11 @@ const transports = [
17
17
  ["sse", "SSE"],
18
18
  ["stdio", "STDIO"]
19
19
  ];
20
+ const tool_type_emojis = {
21
+ tool: "\u{1F527}",
22
+ resource: "\u{1F4D5}",
23
+ prompt: "\u{1F4AC}"
24
+ };
20
25
  $:
21
26
  display_url = current_transport === "sse" ? mcp_server_url : mcp_server_url_streamable;
22
27
  function update_config_with_file_upload(base_config, include_upload) {
@@ -105,7 +110,9 @@ $:
105
110
 
106
111
  <div class="tool-selection">
107
112
  <strong
108
- >{all_tools.length > 0 ? all_tools.length : tools.length} Available MCP Tools</strong
113
+ >{all_tools.length > 0 ? all_tools.length : tools.length} Available MCP Tools
114
+ ({tool_type_emojis.tool}), Resources ({tool_type_emojis.resource}), and
115
+ Prompts ({tool_type_emojis.prompt})</strong
109
116
  >
110
117
  {#if all_tools.length > 0}
111
118
  <div class="tool-selection-controls">
@@ -157,7 +164,10 @@ $:
157
164
  on:click={() => (tool.expanded = !tool.expanded)}
158
165
  >
159
166
  <span
160
- ><span class="tool-name">{tool.name}</span> &nbsp;
167
+ ><span class="tool-name"
168
+ >{tool_type_emojis[tool.meta.mcp_type]} {tool.name}</span
169
+ >
170
+ &nbsp;
161
171
  <span class="tool-description"
162
172
  >{tool.description
163
173
  ? tool.description
@@ -15,6 +15,10 @@ declare const __propDef: {
15
15
  default?: any;
16
16
  }>;
17
17
  expanded?: boolean;
18
+ meta: {
19
+ mcp_type: "tool" | "resource" | "prompt";
20
+ file_data_present: boolean;
21
+ };
18
22
  }[];
19
23
  all_tools?: {
20
24
  name: string;
@@ -27,6 +31,10 @@ declare const __propDef: {
27
31
  default?: any;
28
32
  }>;
29
33
  expanded?: boolean;
34
+ meta: {
35
+ mcp_type: "tool" | "resource" | "prompt";
36
+ file_data_present: boolean;
37
+ };
30
38
  }[] | undefined;
31
39
  selected_tools?: Set<string> | undefined;
32
40
  mcp_json_sse: any;
package/dist/src/init.js CHANGED
@@ -104,9 +104,6 @@ export function create_components({ initial_layout = undefined } = {
104
104
  * Rerender the layout when the config has been modified to attach new components
105
105
  */
106
106
  function rerender_layout({ render_id, components, layout, root, dependencies }) {
107
- // Update current layout and root for dynamic visibility recalculation
108
- current_layout = layout;
109
- current_root = root;
110
107
  components.forEach((c) => {
111
108
  for (const prop in c.props) {
112
109
  if (c.props[prop] === null) {
@@ -241,15 +238,15 @@ export function create_components({ initial_layout = undefined } = {
241
238
  * Load newly visible components after visibility changes
242
239
  * @param newly_visible_ids Set of component IDs that are now visible
243
240
  */
244
- async function load_newly_visible_components(newly_visible_ids) {
241
+ async function load_newly_visible_components(newly_visible_ids, components) {
245
242
  if (newly_visible_ids.size === 0)
246
243
  return;
247
- const components_to_load = _components.filter((c) => newly_visible_ids.has(c.id));
244
+ const components_to_load = components.filter((c) => newly_visible_ids.has(c.id));
248
245
  for (const component of components_to_load) {
249
246
  const constructor_key = component.component_class_id || component.type;
250
247
  // Only load if not already loaded
251
248
  if (!constructor_map.has(constructor_key)) {
252
- const { component: loadable_component, example_components } = get_component(component.type, component.component_class_id, current_root, _components);
249
+ const { component: loadable_component, example_components } = get_component(component.type, component.component_class_id, current_root, components);
253
250
  constructor_map.set(constructor_key, loadable_component);
254
251
  if (example_components) {
255
252
  for (const [name, example_component] of example_components) {
@@ -290,9 +287,12 @@ export function create_components({ initial_layout = undefined } = {
290
287
  function flush() {
291
288
  const had_visibility_changes = has_visibility_changes(pending_updates);
292
289
  let previous_visible_ids;
290
+ const all_components = _component_map
291
+ ? [..._component_map.values()]
292
+ : _components;
293
293
  // Capture current visibility state before applying updates
294
294
  if (had_visibility_changes && current_layout) {
295
- previous_visible_ids = determine_visible_components(current_layout, _components);
295
+ previous_visible_ids = determine_visible_components(current_layout, all_components);
296
296
  }
297
297
  layout_store.update((layout) => {
298
298
  for (let i = 0; i < pending_updates.length; i++) {
@@ -330,7 +330,7 @@ export function create_components({ initial_layout = undefined } = {
330
330
  // After applying updates, check if we need to load new components
331
331
  if (had_visibility_changes && current_layout && previous_visible_ids) {
332
332
  raf(async () => {
333
- const new_visible_ids = determine_visible_components(current_layout, _components);
333
+ const new_visible_ids = determine_visible_components(current_layout, all_components);
334
334
  const newly_visible_ids = new Set();
335
335
  // Find components that are now visible but weren't before
336
336
  for (const id of new_visible_ids) {
@@ -339,7 +339,7 @@ export function create_components({ initial_layout = undefined } = {
339
339
  }
340
340
  }
341
341
  // Load the newly visible components
342
- await load_newly_visible_components(newly_visible_ids);
342
+ await load_newly_visible_components(newly_visible_ids, all_components);
343
343
  // Trigger a layout update to render the newly loaded components
344
344
  if (newly_visible_ids.size > 0) {
345
345
  layout_store.update((layout) => layout);
@@ -62,6 +62,7 @@ export interface Dependency {
62
62
  pending_request?: boolean;
63
63
  trigger_after?: number;
64
64
  trigger_only_on_success?: boolean;
65
+ trigger_only_on_failure?: boolean;
65
66
  trigger_mode: "once" | "multiple" | "always_last";
66
67
  final_event: Payload | null;
67
68
  show_api: boolean;
package/package.json CHANGED
@@ -1,68 +1,68 @@
1
1
  {
2
2
  "name": "@gradio/core",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "type": "module",
5
5
  "devDependencies": {
6
- "@gradio/accordion": "^0.5.20",
7
- "@gradio/atoms": "^0.16.3",
8
- "@gradio/annotatedimage": "^0.9.27",
9
- "@gradio/box": "^0.2.21",
6
+ "@gradio/annotatedimage": "^0.9.29",
7
+ "@gradio/accordion": "^0.5.22",
8
+ "@gradio/audio": "^0.17.25",
9
+ "@gradio/atoms": "^0.16.5",
10
10
  "@gradio/browserstate": "^0.3.2",
11
- "@gradio/audio": "^0.17.23",
12
- "@gradio/chatbot": "^0.26.20",
13
- "@gradio/button": "^0.5.9",
14
- "@gradio/checkboxgroup": "^0.6.25",
15
- "@gradio/checkbox": "^0.4.26",
16
- "@gradio/client": "^1.16.0",
17
- "@gradio/code": "^0.14.13",
18
- "@gradio/colorpicker": "^0.4.25",
11
+ "@gradio/chatbot": "^0.26.22",
12
+ "@gradio/checkbox": "^0.4.28",
13
+ "@gradio/box": "^0.2.23",
14
+ "@gradio/button": "^0.5.11",
15
+ "@gradio/checkboxgroup": "^0.6.27",
16
+ "@gradio/client": "^1.17.1",
17
+ "@gradio/code": "^0.14.15",
18
+ "@gradio/colorpicker": "^0.4.27",
19
19
  "@gradio/column": "^0.2.1",
20
- "@gradio/dataset": "^0.4.30",
21
- "@gradio/dataframe": "^0.18.5",
22
- "@gradio/downloadbutton": "^0.4.9",
23
- "@gradio/datetime": "^0.3.18",
24
- "@gradio/dropdown": "^0.10.0",
25
- "@gradio/file": "^0.12.26",
26
- "@gradio/fileexplorer": "^0.5.37",
27
- "@gradio/fallback": "^0.4.25",
28
- "@gradio/form": "^0.2.21",
29
- "@gradio/gallery": "^0.15.29",
20
+ "@gradio/dataframe": "^0.18.8",
21
+ "@gradio/dropdown": "^0.10.2",
22
+ "@gradio/dataset": "^0.4.32",
23
+ "@gradio/datetime": "^0.3.20",
24
+ "@gradio/downloadbutton": "^0.4.11",
25
+ "@gradio/fallback": "^0.4.27",
26
+ "@gradio/file": "^0.12.28",
27
+ "@gradio/fileexplorer": "^0.5.39",
28
+ "@gradio/form": "^0.2.23",
30
29
  "@gradio/group": "^0.2.0",
31
- "@gradio/highlightedtext": "^0.9.8",
32
- "@gradio/html": "^0.6.17",
33
- "@gradio/icons": "^0.12.0",
34
- "@gradio/image": "^0.22.15",
35
- "@gradio/imageeditor": "^0.16.3",
36
- "@gradio/imageslider": "^0.2.11",
37
- "@gradio/label": "^0.5.17",
38
- "@gradio/multimodaltextbox": "^0.10.15",
39
- "@gradio/markdown": "^0.13.18",
40
- "@gradio/model3d": "^0.14.23",
41
- "@gradio/json": "^0.5.27",
42
- "@gradio/nativeplot": "^0.7.2",
43
- "@gradio/number": "^0.6.2",
44
- "@gradio/paramviewer": "^0.7.13",
45
- "@gradio/plot": "^0.9.20",
46
- "@gradio/radio": "^0.7.8",
30
+ "@gradio/gallery": "^0.15.31",
31
+ "@gradio/highlightedtext": "^0.9.10",
32
+ "@gradio/html": "^0.6.19",
33
+ "@gradio/icons": "^0.13.0",
34
+ "@gradio/image": "^0.22.17",
35
+ "@gradio/imageeditor": "^0.16.5",
36
+ "@gradio/json": "^0.5.29",
37
+ "@gradio/imageslider": "^0.2.13",
38
+ "@gradio/label": "^0.5.19",
39
+ "@gradio/markdown": "^0.13.20",
40
+ "@gradio/model3d": "^0.14.25",
41
+ "@gradio/multimodaltextbox": "^0.10.17",
42
+ "@gradio/number": "^0.6.4",
43
+ "@gradio/nativeplot": "^0.7.4",
44
+ "@gradio/paramviewer": "^0.7.15",
45
+ "@gradio/plot": "^0.9.22",
46
+ "@gradio/radio": "^0.7.10",
47
47
  "@gradio/row": "^0.2.1",
48
- "@gradio/sidebar": "^0.1.18",
49
- "@gradio/simpleimage": "^0.8.37",
50
- "@gradio/simpletextbox": "^0.3.26",
51
- "@gradio/simpledropdown": "^0.3.25",
52
- "@gradio/sketchbox": "^0.6.13",
53
- "@gradio/slider": "^0.6.14",
48
+ "@gradio/sidebar": "^0.1.20",
49
+ "@gradio/simpleimage": "^0.8.39",
50
+ "@gradio/simpletextbox": "^0.3.28",
51
+ "@gradio/simpledropdown": "^0.3.27",
52
+ "@gradio/sketchbox": "^0.6.15",
53
+ "@gradio/slider": "^0.6.16",
54
54
  "@gradio/state": "^0.1.2",
55
55
  "@gradio/tabitem": "^0.5.0",
56
56
  "@gradio/tabs": "^0.4.5",
57
- "@gradio/statustracker": "^0.10.15",
58
- "@gradio/textbox": "^0.10.18",
57
+ "@gradio/textbox": "^0.10.20",
59
58
  "@gradio/theme": "^0.4.0",
60
59
  "@gradio/timer": "^0.4.5",
60
+ "@gradio/statustracker": "^0.10.17",
61
+ "@gradio/upload": "^0.16.15",
62
+ "@gradio/uploadbutton": "^0.9.11",
61
63
  "@gradio/utils": "^0.10.2",
62
- "@gradio/vibeeditor": "^0.2.0",
63
- "@gradio/uploadbutton": "^0.9.9",
64
- "@gradio/video": "^0.14.23",
65
- "@gradio/upload": "^0.16.13",
64
+ "@gradio/video": "^0.15.0",
65
+ "@gradio/vibeeditor": "^0.2.2",
66
66
  "@gradio/wasm": "^0.18.1"
67
67
  },
68
68
  "msw": {
package/src/Blocks.svelte CHANGED
@@ -712,7 +712,10 @@
712
712
  }
713
713
  if (status.stage === "complete") {
714
714
  dependencies.forEach(async (dep) => {
715
- if (dep.trigger_after === fn_index) {
715
+ if (
716
+ dep.trigger_after === fn_index &&
717
+ !dep.trigger_only_on_failure
718
+ ) {
716
719
  wait_then_trigger_api_call(dep.id, payload.trigger_id);
717
720
  }
718
721
  });
@@ -747,7 +750,7 @@
747
750
  dependencies.map(async (dep) => {
748
751
  if (
749
752
  dep.trigger_after === fn_index &&
750
- !dep.trigger_only_on_success
753
+ (!dep.trigger_only_on_success || dep.trigger_only_on_failure)
751
754
  ) {
752
755
  wait_then_trigger_api_call(dep.id, payload.trigger_id);
753
756
  }
@@ -145,6 +145,10 @@
145
145
  description: string;
146
146
  parameters: Record<string, ToolParameter>;
147
147
  expanded?: boolean;
148
+ meta: {
149
+ mcp_type: "tool" | "resource" | "prompt";
150
+ file_data_present: boolean;
151
+ };
148
152
  }
149
153
 
150
154
  let tools: Tool[] = [];
@@ -187,6 +191,7 @@
187
191
  name: tool.name,
188
192
  description: tool.description || "",
189
193
  parameters: tool.inputSchema?.properties || {},
194
+ meta: tool.meta,
190
195
  expanded: false
191
196
  }));
192
197
  selected_tools = new Set(tools.map((tool) => tool.name));
@@ -26,6 +26,10 @@
26
26
  description: string;
27
27
  parameters: Record<string, ToolParameter>;
28
28
  expanded?: boolean;
29
+ meta: {
30
+ mcp_type: "tool" | "resource" | "prompt";
31
+ file_data_present: boolean;
32
+ };
29
33
  }
30
34
 
31
35
  type Transport = "streamable_http" | "sse" | "stdio";
@@ -38,6 +42,12 @@
38
42
  ["stdio", "STDIO"]
39
43
  ] as const;
40
44
 
45
+ const tool_type_emojis = {
46
+ tool: "🔧",
47
+ resource: "📕",
48
+ prompt: "💬"
49
+ };
50
+
41
51
  $: display_url =
42
52
  current_transport === "sse" ? mcp_server_url : mcp_server_url_streamable;
43
53
 
@@ -136,7 +146,9 @@
136
146
 
137
147
  <div class="tool-selection">
138
148
  <strong
139
- >{all_tools.length > 0 ? all_tools.length : tools.length} Available MCP Tools</strong
149
+ >{all_tools.length > 0 ? all_tools.length : tools.length} Available MCP Tools
150
+ ({tool_type_emojis.tool}), Resources ({tool_type_emojis.resource}), and
151
+ Prompts ({tool_type_emojis.prompt})</strong
140
152
  >
141
153
  {#if all_tools.length > 0}
142
154
  <div class="tool-selection-controls">
@@ -188,7 +200,10 @@
188
200
  on:click={() => (tool.expanded = !tool.expanded)}
189
201
  >
190
202
  <span
191
- ><span class="tool-name">{tool.name}</span> &nbsp;
203
+ ><span class="tool-name"
204
+ >{tool_type_emojis[tool.meta.mcp_type]} {tool.name}</span
205
+ >
206
+ &nbsp;
192
207
  <span class="tool-description"
193
208
  >{tool.description
194
209
  ? tool.description
package/src/init.ts CHANGED
@@ -216,10 +216,6 @@ export function create_components(
216
216
  root: string;
217
217
  dependencies: Dependency[];
218
218
  }): void {
219
- // Update current layout and root for dynamic visibility recalculation
220
- current_layout = layout;
221
- current_root = root;
222
-
223
219
  components.forEach((c) => {
224
220
  for (const prop in c.props) {
225
221
  if (c.props[prop] === null) {
@@ -430,11 +426,12 @@ export function create_components(
430
426
  * @param newly_visible_ids Set of component IDs that are now visible
431
427
  */
432
428
  async function load_newly_visible_components(
433
- newly_visible_ids: Set<number>
429
+ newly_visible_ids: Set<number>,
430
+ components: ComponentMeta[]
434
431
  ): Promise<void> {
435
432
  if (newly_visible_ids.size === 0) return;
436
433
 
437
- const components_to_load = _components.filter((c) =>
434
+ const components_to_load = components.filter((c) =>
438
435
  newly_visible_ids.has(c.id)
439
436
  );
440
437
 
@@ -448,7 +445,7 @@ export function create_components(
448
445
  component.type,
449
446
  component.component_class_id,
450
447
  current_root,
451
- _components
448
+ components
452
449
  );
453
450
 
454
451
  constructor_map.set(constructor_key, loadable_component);
@@ -496,12 +493,15 @@ export function create_components(
496
493
  function flush(): void {
497
494
  const had_visibility_changes = has_visibility_changes(pending_updates);
498
495
  let previous_visible_ids: Set<number> | undefined;
496
+ const all_components = _component_map
497
+ ? [..._component_map.values()]
498
+ : _components;
499
499
 
500
500
  // Capture current visibility state before applying updates
501
501
  if (had_visibility_changes && current_layout) {
502
502
  previous_visible_ids = determine_visible_components(
503
503
  current_layout,
504
- _components
504
+ all_components
505
505
  );
506
506
  }
507
507
 
@@ -541,7 +541,7 @@ export function create_components(
541
541
  raf(async () => {
542
542
  const new_visible_ids = determine_visible_components(
543
543
  current_layout,
544
- _components
544
+ all_components
545
545
  );
546
546
  const newly_visible_ids = new Set<number>();
547
547
 
@@ -553,7 +553,7 @@ export function create_components(
553
553
  }
554
554
 
555
555
  // Load the newly visible components
556
- await load_newly_visible_components(newly_visible_ids);
556
+ await load_newly_visible_components(newly_visible_ids, all_components);
557
557
 
558
558
  // Trigger a layout update to render the newly loaded components
559
559
  if (newly_visible_ids.size > 0) {
package/src/types.ts CHANGED
@@ -67,6 +67,7 @@ export interface Dependency {
67
67
  pending_request?: boolean;
68
68
  trigger_after?: number;
69
69
  trigger_only_on_success?: boolean;
70
+ trigger_only_on_failure?: boolean;
70
71
  trigger_mode: "once" | "multiple" | "always_last";
71
72
  final_event: Payload | null;
72
73
  show_api: boolean;