jskinner215 commited on
Commit
af37abc
·
1 Parent(s): 3a49d30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -16,9 +16,8 @@ def ask_llm_chunk(chunk, questions):
16
  st.write(f"An error occurred: {e}")
17
  return ["Error occurred while tokenizing"] * len(questions)
18
 
19
- if inputs["input_ids"].shape[1] > 512:
20
- st.warning("Token limit exceeded for chunk")
21
- return ["Token limit exceeded for chunk"] * len(questions)
22
 
23
  outputs = model(**inputs)
24
  predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions(
@@ -30,11 +29,13 @@ def ask_llm_chunk(chunk, questions):
30
  answers = []
31
  for coordinates in predicted_answer_coordinates:
32
  if len(coordinates) == 1:
 
 
 
 
 
33
  row, col = coordinates[0]
34
  try:
35
- st.write(f"DataFrame shape: {chunk.shape}") # Debugging line
36
- st.write(f"DataFrame columns: {chunk.columns}") # Debugging line
37
- st.write(f"Trying to access row {row}, col {col}") # Debugging line
38
  value = chunk.iloc[row, col]
39
  if isinstance(value, pd.Series):
40
  answers.append(value.values)
@@ -42,6 +43,7 @@ def ask_llm_chunk(chunk, questions):
42
  answers.append(value.item() if hasattr(value, 'item') else value)
43
  except Exception as e:
44
  st.write(f"An error occurred: {e}")
 
45
  else:
46
  cell_values = []
47
  for coordinate in coordinates:
@@ -54,6 +56,7 @@ def ask_llm_chunk(chunk, questions):
54
  cell_values.append(value.item() if hasattr(value, 'item') else value)
55
  except Exception as e:
56
  st.write(f"An error occurred: {e}")
 
57
  answers.append(", ".join(map(str, cell_values)))
58
 
59
  return answers
 
16
  st.write(f"An error occurred: {e}")
17
  return ["Error occurred while tokenizing"] * len(questions)
18
 
19
+ # Debugging line
20
+ st.write(f"Token shape: {inputs['input_ids'].shape[1]}")
 
21
 
22
  outputs = model(**inputs)
23
  predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions(
 
29
  answers = []
30
  for coordinates in predicted_answer_coordinates:
31
  if len(coordinates) == 1:
32
+ # Debugging lines
33
+ st.write(f"DataFrame shape: {chunk.shape}")
34
+ st.write(f"DataFrame columns: {chunk.columns}")
35
+ st.write(f"Trying to access row {coordinates[0][0]}, col {coordinates[0][1]}")
36
+
37
  row, col = coordinates[0]
38
  try:
 
 
 
39
  value = chunk.iloc[row, col]
40
  if isinstance(value, pd.Series):
41
  answers.append(value.values)
 
43
  answers.append(value.item() if hasattr(value, 'item') else value)
44
  except Exception as e:
45
  st.write(f"An error occurred: {e}")
46
+ answers.append("Error")
47
  else:
48
  cell_values = []
49
  for coordinate in coordinates:
 
56
  cell_values.append(value.item() if hasattr(value, 'item') else value)
57
  except Exception as e:
58
  st.write(f"An error occurred: {e}")
59
+ cell_values.append("Error")
60
  answers.append(", ".join(map(str, cell_values)))
61
 
62
  return answers