Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 7 |
-
|
| 8 |
-
def
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|