tstone87 commited on
Commit
b817db2
·
verified ·
1 Parent(s): 87c42f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -13,9 +13,12 @@ def load_json_data():
13
  with open(DATA_FILE, "r", encoding="utf-8") as f:
14
  data = json.load(f)
15
 
16
- # Convert list to dictionary if needed
17
  if isinstance(data, list):
18
- data = {list(entry.keys())[0]: list(entry.values())[0] for entry in data if isinstance(entry, dict)}
 
 
 
19
 
20
  return data
21
  except (FileNotFoundError, ValueError) as e:
@@ -62,4 +65,4 @@ def chatbot_response(message, history):
62
  # 🔹 Gradio Chat Interface
63
  demo = gr.ChatInterface(chatbot_response, textbox=gr.Textbox(placeholder="Ask about Colorado food stamps..."))
64
 
65
- demo.launch()
 
13
  with open(DATA_FILE, "r", encoding="utf-8") as f:
14
  data = json.load(f)
15
 
16
+ # Ensure data is a dictionary, not a list
17
  if isinstance(data, list):
18
+ data = {str(i): str(entry) for i, entry in enumerate(data)}
19
+
20
+ # Convert all values to strings
21
+ data = {key: str(value) for key, value in data.items()}
22
 
23
  return data
24
  except (FileNotFoundError, ValueError) as e:
 
65
  # 🔹 Gradio Chat Interface
66
  demo = gr.ChatInterface(chatbot_response, textbox=gr.Textbox(placeholder="Ask about Colorado food stamps..."))
67
 
68
+ demo.launch()