Spaces:
Build error
Build error
Commit ·
45ee012
1
Parent(s): 66f9f66
Update app.py
Browse files1234525 unmodified lines3132333233343536373839404138394240414344444546454647484950515253545556575051525358596061625963646566from copy import deepcopy
import streamlit as stimport pandas as pdfrom io import StringIO25 unmodified lines
answers = [] for coordinates in predicted_answer_coordinates: for coordinate in coordinates: row, col = coordinate if len(coordinates) == 1: row, col = coordinates[0] try: st.write(f"DataFrame shape: {chunk.shape}") # Debugging line st.write(f"DataFrame columns: {chunk.columns}") # Debugging line st.write(f"Trying to access row {row}, col {col}") # Debugging line value = chunk.iloc[row, col] st.write(f"Value accessed: {value}") # Debugging line if isinstance(value, pd.Series): answers.append(value.values) answers.append(value) else: answers.append(value.item() if hasattr(value, 'item') else value) except Exception as e: st.write(f"An error occurred: {e}") st.write(f"Type of error: {type(e)}") st.write(f"Arguments of error: {e.args}") answers.append(", ".join(map(str, [chunk.iloc[coordinate].values for coordinate in coordinates]))) else: cell_values = [] for coordinate in coordinates: row, col = coordinate try: value = chunk.iloc[row, col] cell_values.append(value) except Exception as e: st.write(f"An error occurred: {e}") answers.append(", ".join(map(str, cell_values)))
return answers
MAX_ROWS_PER_CHUNK = 200
def summarize_map_reduce(data, questions): dataframe = pd.read_csv(StringIO(data)) num_chunks = len(dataframe) // MAX_ROWS_PER_CHUNK + 1 dataframe_chunks = np.array_split(dataframe, num_chunks) dataframe_chunks = [deepcopy(chunk) for chunk in np.array_split(dataframe, num_chunks)] all_answers = [] for chunk in dataframe_chunks: chunk_answers = ask_llm_chunk(chunk, questions)app.py+18-14