Update app.py
#1
by
bulbasour
- opened
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import os
|
2 |
import sys
|
3 |
|
4 |
-
|
5 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
6 |
|
7 |
# Import libraries
|
@@ -11,9 +11,9 @@ import torch
|
|
11 |
from transformers import BertTokenizer, BertForSequenceClassification, pipeline
|
12 |
from app.questions import get_question
|
13 |
|
14 |
-
#
|
15 |
try:
|
16 |
-
#
|
17 |
original_method = gr.Blocks.get_api_info
|
18 |
|
19 |
# Create a safer version of the method that catches the specific error
|
@@ -22,9 +22,9 @@ try:
|
|
22 |
return original_method(self)
|
23 |
except TypeError as e:
|
24 |
print(f"API info generation error suppressed: {str(e)}", file=sys.stderr)
|
25 |
-
return {} # Return empty
|
26 |
|
27 |
-
|
28 |
gr.Blocks.get_api_info = safe_get_api_info
|
29 |
print("Applied API info generation patch", file=sys.stderr)
|
30 |
except Exception as e:
|
@@ -189,15 +189,15 @@ try:
|
|
189 |
# Original function reference
|
190 |
original_json_schema = gradio_client.utils._json_schema_to_python_type
|
191 |
|
192 |
-
#
|
193 |
def patched_json_schema(schema, defs=None):
|
194 |
try:
|
195 |
if isinstance(schema, bool):
|
196 |
-
return "bool"
|
197 |
return original_json_schema(schema, defs)
|
198 |
except Exception as e:
|
199 |
print(f"JSON schema conversion error suppressed: {str(e)}", file=sys.stderr)
|
200 |
-
return "any"
|
201 |
|
202 |
# Apply patch
|
203 |
gradio_client.utils._json_schema_to_python_type = patched_json_schema
|
@@ -211,7 +211,7 @@ if __name__ == "__main__":
|
|
211 |
demo.launch(show_api=False)
|
212 |
except Exception as e:
|
213 |
print(f"Launch failed: {str(e)}", file=sys.stderr)
|
214 |
-
|
215 |
try:
|
216 |
demo.launch()
|
217 |
except Exception as e:
|
|
|
1 |
import os
|
2 |
import sys
|
3 |
|
4 |
+
|
5 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
6 |
|
7 |
# Import libraries
|
|
|
11 |
from transformers import BertTokenizer, BertForSequenceClassification, pipeline
|
12 |
from app.questions import get_question
|
13 |
|
14 |
+
# patch(niranjan)
|
15 |
try:
|
16 |
+
# original method
|
17 |
original_method = gr.Blocks.get_api_info
|
18 |
|
19 |
# Create a safer version of the method that catches the specific error
|
|
|
22 |
return original_method(self)
|
23 |
except TypeError as e:
|
24 |
print(f"API info generation error suppressed: {str(e)}", file=sys.stderr)
|
25 |
+
return {} # Return empty api
|
26 |
|
27 |
+
|
28 |
gr.Blocks.get_api_info = safe_get_api_info
|
29 |
print("Applied API info generation patch", file=sys.stderr)
|
30 |
except Exception as e:
|
|
|
189 |
# Original function reference
|
190 |
original_json_schema = gradio_client.utils._json_schema_to_python_type
|
191 |
|
192 |
+
# patched version
|
193 |
def patched_json_schema(schema, defs=None):
|
194 |
try:
|
195 |
if isinstance(schema, bool):
|
196 |
+
return "bool"
|
197 |
return original_json_schema(schema, defs)
|
198 |
except Exception as e:
|
199 |
print(f"JSON schema conversion error suppressed: {str(e)}", file=sys.stderr)
|
200 |
+
return "any"
|
201 |
|
202 |
# Apply patch
|
203 |
gradio_client.utils._json_schema_to_python_type = patched_json_schema
|
|
|
211 |
demo.launch(show_api=False)
|
212 |
except Exception as e:
|
213 |
print(f"Launch failed: {str(e)}", file=sys.stderr)
|
214 |
+
|
215 |
try:
|
216 |
demo.launch()
|
217 |
except Exception as e:
|