Mohinikathro commited on
Commit
60ad7ee
·
verified ·
1 Parent(s): 2f16432

changes made to app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -4,6 +4,22 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, AutoModelForCausa
4
  import torch
5
  import os
6
  import gradio_client.utils as client_utils
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  # Workaround for Gradio schema generation issue
9
  def _patched_json_schema_to_python_type(schema, defs=None):
 
4
  import torch
5
  import os
6
  import gradio_client.utils as client_utils
7
+ import sys
8
+
9
+ # ================== FIX START ==================
10
+ # Store original reference first
11
+ _original_json_schema_handler = client_utils._json_schema_to_python_type
12
+
13
+ def _patched_json_schema_to_python_type(schema, defs=None, depth=0):
14
+ if depth > 100: # Safety net
15
+ return "Any"
16
+ if isinstance(schema, bool):
17
+ return "Any" if schema else "None"
18
+ return _original_json_schema_handler(schema, defs)
19
+
20
+ client_utils._json_schema_to_python_type = _patched_json_schema_to_python_type
21
+ sys.setrecursionlimit(10000) # Temporarily increase recursion depth
22
+ # ================== FIX END ====================
23
 
24
  # Workaround for Gradio schema generation issue
25
  def _patched_json_schema_to_python_type(schema, defs=None):