shreyasiv commited on
Commit
ea35d0c
·
1 Parent(s): 964863a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -19,7 +19,7 @@ def main():
19
  return
20
 
21
  st.sidebar.image("https://i.ibb.co/bX6GdqG/insightly-wbg.png", use_column_width=True)
22
- st.title("Chat with Columns 💬")
23
 
24
  csv_files = st.file_uploader("Upload CSV files", type="csv", accept_multiple_files=True)
25
  if csv_files:
@@ -53,17 +53,19 @@ def main():
53
  st.error(f"The column '{column_for_prompt}' does not exist in the CSV file: {csv_file.name}")
54
  continue
55
 
56
- # Perform any necessary data preprocessing or feature engineering here
57
- # You can modify the code based on your specific requirements
58
 
59
  # Example: Accessing columns from the DataFrame
60
  column_data = df[column_for_prompt]
61
 
62
  # Loop through each row in the specified column and pass the user input as prompt
63
  for row_value in column_data:
64
- original_rows_list.append(row_value)
 
 
 
65
  # Example: Using the preprocessed data with the OpenAI API
66
- llm_response = llm.predict(row_value + " " + user_input)
67
  responses_list.append(llm_response)
68
 
69
  # Introduce a delay of 1 second between API calls to reduce the rate of requests
@@ -75,10 +77,14 @@ def main():
75
  "Responses": responses_list
76
  })
77
 
 
 
 
78
  # Offer the option to download the responses as a CSV file
79
  if st.button("Download Responses as CSV"):
80
  with BytesIO() as output_file:
81
  response_df.to_csv(output_file, index=False)
 
82
  st.download_button(
83
  label="Download CSV",
84
  data=output_file.getvalue(),
@@ -87,4 +93,4 @@ def main():
87
  )
88
 
89
  if __name__ == "__main__":
90
- main()
 
19
  return
20
 
21
  st.sidebar.image("https://i.ibb.co/bX6GdqG/insightly-wbg.png", use_column_width=True)
22
+ st.title("Column Analysis 💬")
23
 
24
  csv_files = st.file_uploader("Upload CSV files", type="csv", accept_multiple_files=True)
25
  if csv_files:
 
53
  st.error(f"The column '{column_for_prompt}' does not exist in the CSV file: {csv_file.name}")
54
  continue
55
 
56
+
 
57
 
58
  # Example: Accessing columns from the DataFrame
59
  column_data = df[column_for_prompt]
60
 
61
  # Loop through each row in the specified column and pass the user input as prompt
62
  for row_value in column_data:
63
+ # Convert the row value to a string to handle missing or NaN values
64
+ row_value_str = str(row_value)
65
+ original_rows_list.append(row_value_str)
66
+
67
  # Example: Using the preprocessed data with the OpenAI API
68
+ llm_response = llm.predict(row_value_str + " " + user_input)
69
  responses_list.append(llm_response)
70
 
71
  # Introduce a delay of 1 second between API calls to reduce the rate of requests
 
77
  "Responses": responses_list
78
  })
79
 
80
+ # Add bold formatting to the "Responses" column
81
+ response_df["Responses"] = response_df["Responses"].apply(lambda x: f"**{x}**")
82
+
83
  # Offer the option to download the responses as a CSV file
84
  if st.button("Download Responses as CSV"):
85
  with BytesIO() as output_file:
86
  response_df.to_csv(output_file, index=False)
87
+
88
  st.download_button(
89
  label="Download CSV",
90
  data=output_file.getvalue(),
 
93
  )
94
 
95
  if __name__ == "__main__":
96
+ main()