Rulga commited on
Commit
e6789a5
·
1 Parent(s): 2143f1a

Refactor table selection handler in app.py: Improve row selection logic for clarity and reliability

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1205,14 +1205,17 @@ with gr.Blocks(css="""
1205
  outputs=[qa_table]
1206
  )
1207
 
1208
- # Обработчик выбора строки в таблице
1209
  def on_table_select(evt: gr.SelectData) -> str:
1210
  """Handle table row selection"""
1211
  try:
1212
- # Get the full row data
1213
- row_data = evt.data
1214
- # Return the full Conversation ID from the first column
1215
- return row_data[0]
 
 
 
 
1216
  except Exception as e:
1217
  logger.error(f"Error in table selection: {str(e)}")
1218
  return ""
 
1205
  outputs=[qa_table]
1206
  )
1207
 
 
1208
  def on_table_select(evt: gr.SelectData) -> str:
1209
  """Handle table row selection"""
1210
  try:
1211
+ # Get the selected row index and column index
1212
+ row_index = evt.index[0]
1213
+
1214
+ # Get the DataFrame from qa_table state
1215
+ df = qa_table.value
1216
+
1217
+ # Return the full Conversation ID from the first column of selected row
1218
+ return df.iloc[row_index, 0] # First column (0) contains Conversation ID
1219
  except Exception as e:
1220
  logger.error(f"Error in table selection: {str(e)}")
1221
  return ""