SamiKoen Claude commited on
Commit
cad0b30
·
1 Parent(s): 3e7fdcd

Fix NameError and deprecation warning

Browse files

- Fixed create_json_html function order (defined before usage)
- Added type="tuples" to Chatbot to fix deprecation warning
- Function now properly accessible when creating HTML component

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -1072,7 +1072,7 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı", head=storag
1072
 
1073
  # LocalStorage fonksiyonu kaldırıldı
1074
 
1075
- chatbot = gr.Chatbot(height=600, elem_id="chatbot", show_label=False)
1076
 
1077
  msg = gr.Textbox(
1078
  placeholder="Trek bisikletleri hakkında soru sorun...",
@@ -1179,15 +1179,7 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı", head=storag
1179
  # Auto-load on start
1180
  demo.load(get_conversations_json, outputs=json_display)
1181
 
1182
- # Add HTML component with embedded JSON for external access
1183
- with gr.Row(visible=False):
1184
- # Create an HTML element that contains the JSON data
1185
- json_html = gr.HTML(
1186
- value=lambda: create_json_html(),
1187
- visible=False,
1188
- elem_id="json_data_container"
1189
- )
1190
-
1191
  def create_json_html():
1192
  """Create HTML with embedded JSON data"""
1193
  from conversation_tracker import load_conversations
@@ -1202,6 +1194,15 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı", head=storag
1202
  </div>
1203
  '''
1204
 
 
 
 
 
 
 
 
 
 
1205
  # Update JSON HTML every 5 seconds
1206
  demo.load(create_json_html, outputs=json_html, every=5)
1207
 
 
1072
 
1073
  # LocalStorage fonksiyonu kaldırıldı
1074
 
1075
+ chatbot = gr.Chatbot(height=600, elem_id="chatbot", show_label=False, type="tuples")
1076
 
1077
  msg = gr.Textbox(
1078
  placeholder="Trek bisikletleri hakkında soru sorun...",
 
1179
  # Auto-load on start
1180
  demo.load(get_conversations_json, outputs=json_display)
1181
 
1182
+ # Define function for JSON HTML before using it
 
 
 
 
 
 
 
 
1183
  def create_json_html():
1184
  """Create HTML with embedded JSON data"""
1185
  from conversation_tracker import load_conversations
 
1194
  </div>
1195
  '''
1196
 
1197
+ # Add HTML component with embedded JSON for external access
1198
+ with gr.Row(visible=False):
1199
+ # Create an HTML element that contains the JSON data
1200
+ json_html = gr.HTML(
1201
+ value=create_json_html(), # Call directly, not as lambda
1202
+ visible=False,
1203
+ elem_id="json_data_container"
1204
+ )
1205
+
1206
  # Update JSON HTML every 5 seconds
1207
  demo.load(create_json_html, outputs=json_html, every=5)
1208