Spaces:
Build error
Build error
Commit ·
45ee012
1
Parent(s): 66f9f66
Update app.py
Browse files12325 unmodified lines29303132333435363738394041424344454647484950515253545556575859606162import streamlit as stimport pandas as pdfrom io import StringIO25 unmodified linesanswers = []for coordinates in predicted_answer_coordinates:for coordinate in coordinates:row, col = coordinatetry:st.write(f"Trying to access row {row}, col {col}") # Debugging linevalue = chunk.iloc[row, col]st.write(f"Value accessed: {value}") # Debugging lineif isinstance(value, pd.Series):answers.append(value.values)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])))return answersMAX_ROWS_PER_CHUNK = 200def summarize_map_reduce(data, questions):dataframe = pd.read_csv(StringIO(data))num_chunks = len(dataframe) // MAX_ROWS_PER_CHUNK + 1dataframe_chunks = np.array_split(dataframe, num_chunks)all_answers = []for chunk in dataframe_chunks:chunk_answers = ask_llm_chunk(chunk, questions)1234525 unmodified lines313233343536373839404142434445464748495051525354555657585960616263646566from copy import deepcopyimport streamlit as stimport pandas as pdfrom io import StringIO25 unmodified linesanswers = []for coordinates in predicted_answer_coordinates:if len(coordinates) == 1:row, col = coordinates[0]try:st.write(f"DataFrame shape: {chunk.shape}") # Debugging linest.write(f"DataFrame columns: {chunk.columns}") # Debugging linest.write(f"Trying to access row {row}, col {col}") # Debugging linevalue = chunk.iloc[row, col]st.write(f"Value accessed: {value}") # Debugging lineanswers.append(value)except Exception as e:st.write(f"An error occurred: {e}")else:cell_values = []for coordinate in coordinates:row, col = coordinatetry: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 answersMAX_ROWS_PER_CHUNK = 200def summarize_map_reduce(data, questions):dataframe = pd.read_csv(StringIO(data))num_chunks = len(dataframe) // MAX_ROWS_PER_CHUNK + 1dataframe_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