owenkaplinsky commited on
Commit
3974968
·
1 Parent(s): 2f2e165

Add Any type

Browse files
project/src/blocks/text.js CHANGED
@@ -504,6 +504,7 @@ const container_input = {
504
  ["Float", "float"],
505
  ["List", "list"],
506
  ["Boolean", "boolean"],
 
507
  ]
508
  },
509
  { type: "field_input", name: "NAME" },
@@ -526,6 +527,7 @@ const container_output = {
526
  ["Float", "float"],
527
  ["List", "list"],
528
  ["Boolean", "boolean"],
 
529
  ]
530
  },
531
  { type: "field_input", name: "NAME" },
 
504
  ["Float", "float"],
505
  ["List", "list"],
506
  ["Boolean", "boolean"],
507
+ ["Any", "any"],
508
  ]
509
  },
510
  { type: "field_input", name: "NAME" },
 
527
  ["Float", "float"],
528
  ["List", "list"],
529
  ["Boolean", "boolean"],
530
+ ["Any", "any"],
531
  ]
532
  },
533
  { type: "field_input", name: "NAME" },
project/src/generators/python.js CHANGED
@@ -123,6 +123,9 @@ forBlock['create_mcp'] = function (block, generator) {
123
  case 'boolean':
124
  gradioInputs.push('gr.Checkbox()');
125
  break;
 
 
 
126
  default:
127
  gradioInputs.push('gr.Textbox()');
128
  }
@@ -152,6 +155,9 @@ forBlock['create_mcp'] = function (block, generator) {
152
  case 'boolean':
153
  gradioOutputs.push('gr.Checkbox()');
154
  break;
 
 
 
155
  default:
156
  gradioOutputs.push('gr.Textbox()');
157
  }
 
123
  case 'boolean':
124
  gradioInputs.push('gr.Checkbox()');
125
  break;
126
+ case 'any':
127
+ gradioInputs.push('gr.JSON()');
128
+ break;
129
  default:
130
  gradioInputs.push('gr.Textbox()');
131
  }
 
155
  case 'boolean':
156
  gradioOutputs.push('gr.Checkbox()');
157
  break;
158
+ case 'any':
159
+ gradioOutputs.push('gr.JSON()');
160
+ break;
161
  default:
162
  gradioOutputs.push('gr.Textbox()');
163
  }
project/test.py CHANGED
@@ -250,6 +250,8 @@ def build_interface():
250
  display_type = 'float'
251
  elif 'list' in type_hint:
252
  display_type = 'list'
 
 
253
  else:
254
  display_type = 'string'
255
  params.append({
@@ -283,13 +285,14 @@ def build_interface():
283
  out_types = []
284
  else:
285
  out_types = []
286
- # Convert output types: handle string, integer, float, list, boolean
287
  out_types = [
288
  "string" if t == "str" else
289
  "integer" if t == "int" else
290
  "float" if t == "float" else
291
  "list" if t == "list" else
292
- "boolean" if t == "bool" else t
 
293
  for t in out_types
294
  ]
295
 
@@ -336,7 +339,8 @@ def build_interface():
336
  "integer" if t == "int" else
337
  "float" if t == "float" else
338
  "list" if t == "list" else
339
- "boolean" if t == "bool" else t
 
340
  for t in out_types
341
  ]
342
  except Exception:
@@ -344,8 +348,8 @@ def build_interface():
344
 
345
  # If result is a tuple or list
346
  if isinstance(result, (tuple, list)):
347
- # Check if the first output type is "list" - if so, convert to string representation
348
- if out_types and out_types[0] == "list":
349
  return [str(result)] + [""] * 9
350
  else:
351
  # Multiple outputs - each item is a separate output
 
250
  display_type = 'float'
251
  elif 'list' in type_hint:
252
  display_type = 'list'
253
+ elif 'bool' in type_hint:
254
+ display_type = 'boolean'
255
  else:
256
  display_type = 'string'
257
  params.append({
 
285
  out_types = []
286
  else:
287
  out_types = []
288
+ # Convert output types: handle string, integer, float, list, boolean, any
289
  out_types = [
290
  "string" if t == "str" else
291
  "integer" if t == "int" else
292
  "float" if t == "float" else
293
  "list" if t == "list" else
294
+ "boolean" if t == "bool" else
295
+ "any" if t == "Any" else t
296
  for t in out_types
297
  ]
298
 
 
339
  "integer" if t == "int" else
340
  "float" if t == "float" else
341
  "list" if t == "list" else
342
+ "boolean" if t == "bool" else
343
+ "any" if t == "Any" else t
344
  for t in out_types
345
  ]
346
  except Exception:
 
348
 
349
  # If result is a tuple or list
350
  if isinstance(result, (tuple, list)):
351
+ # Check if the first output type is "list" or "any" - if so, convert to string representation
352
+ if out_types and out_types[0] in ("list", "any"):
353
  return [str(result)] + [""] * 9
354
  else:
355
  # Multiple outputs - each item is a separate output