Spaces:
Build error
Build error
Commit
·
515be2e
1
Parent(s):
c1ca766
more iloc errors and (str)
Browse filesThe iloc operation seems to be returning a single value (in this case, a string) rather than a Series or DataFrame. This is why you're seeing the error 'str' object has no attribute 'values'.
The error iloc cannot enlarge its target object suggests that we're trying to access an index that might be out of bounds.
Based on these issues, I propose the following adjustments:
Replace .values with .item() for scalar values, which will safely convert single values to their respective native Python types.
Add some additional checks and logging to understand the shape and type of data you're working with.
app.py
CHANGED
@@ -16,7 +16,6 @@ def ask_llm_chunk(chunk, questions):
|
|
16 |
st.write(f"An error occurred: {e}")
|
17 |
return ["Error occurred while tokenizing"] * len(questions)
|
18 |
|
19 |
-
# Check for token limit
|
20 |
if inputs["input_ids"].shape[1] > 512:
|
21 |
st.warning("Token limit exceeded for chunk")
|
22 |
return ["Token limit exceeded for chunk"] * len(questions)
|
@@ -27,28 +26,35 @@ def ask_llm_chunk(chunk, questions):
|
|
27 |
outputs.logits.detach(),
|
28 |
outputs.logits_aggregation.detach()
|
29 |
)
|
30 |
-
|
31 |
-
st.write(f"Testing DataFrame iloc: {chunk.iloc[0, 8]}") # Debugging line
|
32 |
-
|
33 |
answers = []
|
34 |
for coordinates in predicted_answer_coordinates:
|
35 |
if len(coordinates) == 1:
|
|
|
36 |
try:
|
37 |
-
st.write(f"Trying to access row {
|
38 |
-
|
|
|
|
|
|
|
|
|
39 |
except Exception as e:
|
40 |
st.write(f"An error occurred: {e}")
|
41 |
else:
|
42 |
cell_values = []
|
43 |
for coordinate in coordinates:
|
|
|
44 |
try:
|
45 |
-
|
|
|
|
|
|
|
|
|
46 |
except Exception as e:
|
47 |
st.write(f"An error occurred: {e}")
|
48 |
-
answers.append(", ".join(cell_values))
|
49 |
-
return answers
|
50 |
-
|
51 |
|
|
|
52 |
|
53 |
|
54 |
|
|
|
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)
|
|
|
26 |
outputs.logits.detach(),
|
27 |
outputs.logits_aggregation.detach()
|
28 |
)
|
29 |
+
|
|
|
|
|
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"Trying to access row {row}, col {col}") # Debugging line
|
36 |
+
value = chunk.iloc[row, col]
|
37 |
+
if isinstance(value, pd.Series):
|
38 |
+
answers.append(value.values)
|
39 |
+
else:
|
40 |
+
answers.append(value.item() if hasattr(value, 'item') else value)
|
41 |
except Exception as e:
|
42 |
st.write(f"An error occurred: {e}")
|
43 |
else:
|
44 |
cell_values = []
|
45 |
for coordinate in coordinates:
|
46 |
+
row, col = coordinate
|
47 |
try:
|
48 |
+
value = chunk.iloc[row, col]
|
49 |
+
if isinstance(value, pd.Series):
|
50 |
+
cell_values.append(value.values)
|
51 |
+
else:
|
52 |
+
cell_values.append(value.item() if hasattr(value, 'item') else value)
|
53 |
except Exception as e:
|
54 |
st.write(f"An error occurred: {e}")
|
55 |
+
answers.append(", ".join(map(str, cell_values)))
|
|
|
|
|
56 |
|
57 |
+
return answers
|
58 |
|
59 |
|
60 |
|