Spaces:
Sleeping
Sleeping
Update app.py
Browse files1609 unmodified lines161016111612161316141615161616171618161916201621162216231624162516264 unmodified lines16311632163316341635163655 unmodified lines16921693169416951696169716981699170017011609 unmodified linesglobal df_builder_pivot_strtry:# Get the current value of selected_dataset_aiselected_dataset_ai = read_ai_dataset_selection()# Recompute DATAFRAME_PROOF_POINT based on the selected datasetdf_builder_pivot_str = compute_dataframe_proof_point()# Generate response using the agent executoroutput = agent_executor.invoke({"input": message, "chat_history": chat_history})# Prepend the selected dataset to the responseresponse = f"**Selected Dataset: {selected_dataset_ai}**\n\n{output['output']}"# Save the interaction contextchat_history.extend(4 unmodified lines)return responseexcept Exception as e:logger.error(f"Error generating chatbot response: {e}")return "Error occurred during response generation"55 unmodified linesreturn plot_to_svg(fig2)def update_ai_dataset_selection(selection):global selected_dataset_aiselected_dataset_ai = selectionreturn selection1609 unmodified lines1610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216334 unmodified lines163816391640164116421643164455 unmodified lines17001701170217031704170517061707170817091710171117121609 unmodified linesglobal df_builder_pivot_strtry:# Recompute DATAFRAME_PROOF_POINT based on the updated selected datasetif selected_dataset_ai is None:selected_dataset_ai = read_ai_dataset_selection()df_builder_pivot_str = compute_dataframe_proof_point(selected_dataset_ai)# Check if DATAFRAME_PROOF_POINT is computed correctlyif not df_builder_pivot_str:# Fall back to general knowledge if DATAFRAME_PROOF_POINT is emptyresponse = ("Trust Builder information is not given, I will reply based on general knowledge.")else:# Generate response using the agent executoroutput = agent_executor.invoke({"input": message, "chat_history": chat_history})# Prepend the selected dataset to the responseresponse = f"**Selected Dataset: {selected_dataset_ai}**\n\n{output['output']}"# Save the interaction contextchat_history.extend(4 unmodified lines)return responseexcept Exception as e:logger.error(f"Error generating chatbot response: {e}")return "Error occurred during response generation"55 unmodified linesreturn plot_to_svg(fig2)def update_ai_dataset_selection(selection):global selected_dataset_aiselected_dataset_ai = selection# Recompute DATAFRAME_PROOF_POINT after updating the datasetcompute_dataframe_proof_point(selected_dataset_ai)return selection
app.py+20-9