davidberenstein1957 HF staff commited on
Commit
d3fc1a4
1 Parent(s): aa23dc4

fix: gradio cached examples

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +5 -5
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
app.py CHANGED
@@ -33,13 +33,13 @@ def process_fields(fields):
33
  def process_records_gradio(records, fields, question, example_records=None):
34
  try:
35
  # Convert string inputs to dictionaries
36
- if isinstance(records, str):
37
  records = json.loads(records)
38
- if isinstance(example_records, str):
39
  example_records = json.loads(example_records)
40
- if isinstance(fields, str):
41
  fields = json.loads(fields)
42
- if isinstance(question, str):
43
  question = json.loads(question)
44
 
45
  if not fields and not question:
@@ -60,7 +60,7 @@ def process_records_gradio(records, fields, question, example_records=None):
60
 
61
  return json.dumps({"results": results}, indent=2)
62
  except Exception as e:
63
- raise Exception(f"Error: {str(e)}")
64
 
65
 
66
  description = """
 
33
  def process_records_gradio(records, fields, question, example_records=None):
34
  try:
35
  # Convert string inputs to dictionaries
36
+ if isinstance(records, str) and records:
37
  records = json.loads(records)
38
+ if isinstance(example_records, str) and example_records:
39
  example_records = json.loads(example_records)
40
+ if isinstance(fields, str) and fields:
41
  fields = json.loads(fields)
42
+ if isinstance(question, str) and question:
43
  question = json.loads(question)
44
 
45
  if not fields and not question:
 
60
 
61
  return json.dumps({"results": results}, indent=2)
62
  except Exception as e:
63
+ raise gr.Error(f"Error: {str(e)}")
64
 
65
 
66
  description = """