bangadu commited on
Commit
8669429
·
verified ·
1 Parent(s): c7606b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -1,17 +1,25 @@
1
  import yaml
2
  import os
3
 
4
- # Monkey patch for Gradio compatibility
5
  import gradio as gr
6
- _original_blocks_init__ = gr.Blocks.__init__
7
-
8
- def patched_blocks_init(self, *args, **kwargs):
9
- # Remove unsupported kwargs
10
- kwargs.pop('theme', None)
11
- kwargs.pop('fill_height', None)
12
- _original_blocks_init__(self, *args, **kwargs)
13
-
14
- gr.Blocks.__init__ = patched_blocks_init
 
 
 
 
 
 
 
 
15
  from smolagents import GradioUI, CodeAgent, InferenceClientModel
16
 
17
  # Get current directory path
 
1
  import yaml
2
  import os
3
 
4
+ # Monkey patch for Gradio compatibility - remove unsupported kwargs from components
5
  import gradio as gr
6
+ from functools import wraps
7
+
8
+ def create_wrapper(original_init):
9
+ @wraps(original_init)
10
+ def wrapper(self, *args, **kwargs):
11
+ # List of kwargs to remove for compatibility
12
+ unsupported_kwargs = ['theme', 'fill_height', 'type', 'scale', 'min_width']
13
+ for kwarg in unsupported_kwargs:
14
+ kwargs.pop(kwarg, None)
15
+ return original_init(self, *args, **kwargs)
16
+ return wrapper
17
+
18
+ # Patch Blocks, Chatbot, Textbox, and other components
19
+ for component_name in ['Blocks', 'Chatbot', 'Textbox', 'Button', 'Slider', 'Dropdown', 'Radio', 'Checkbox', 'Number', 'Image', 'Audio', 'Video']:
20
+ if hasattr(gr, component_name):
21
+ component = getattr(gr, component_name)
22
+ component.__init__ = create_wrapper(component.__init__)
23
  from smolagents import GradioUI, CodeAgent, InferenceClientModel
24
 
25
  # Get current directory path