Priti0210 commited on
Commit
944c441
·
1 Parent(s): 3bc14fc

updated tabulate use

Browse files
Files changed (2) hide show
  1. app.py +20 -10
  2. requirements.txt +1 -0
app.py CHANGED
@@ -126,24 +126,26 @@ def process_data(file_obj, model_col: str, train_col: str, data_source: str) ->
126
  return f"An error occurred: {str(e)}", None, None, None, None, None, None
127
 
128
 
129
- def update_dropdowns(file_obj) -> Tuple[list, str]:
130
  """Updates dropdown choices based on the uploaded file."""
131
  if not file_obj:
132
- return [], "No file uploaded."
133
 
134
- file_path = file_obj.name
135
  try:
136
- if file_path.endswith(".csv"):
137
- df = pd.read_csv(file_path)
138
- elif file_path.endswith(".json"):
139
- df = pd.read_json(file_path)
 
140
  else:
141
- return [], "Invalid file type."
 
142
  columns = df.columns.tolist()
143
  preview = df.head().to_markdown(index=False, numalign="left", stralign="left")
144
- return columns, preview
 
145
  except Exception as e:
146
- return [], f"Error reading file: {e}"
147
 
148
 
149
  def main_interface():
@@ -193,6 +195,14 @@ def main_interface():
193
  file_input = gr.File(
194
  file_types=[".csv", ".json"], label="Upload a CSV or JSON file"
195
  )
 
 
 
 
 
 
 
 
196
 
197
  with gr.Row():
198
  model_col_input = gr.Dropdown(
 
126
  return f"An error occurred: {str(e)}", None, None, None, None, None, None
127
 
128
 
129
+ def update_dropdowns(file_obj) -> Tuple[list, list, str]:
130
  """Updates dropdown choices based on the uploaded file."""
131
  if not file_obj:
132
+ return [], [], "No file uploaded."
133
 
 
134
  try:
135
+ file_name = getattr(file_obj, "name", "")
136
+ if file_name.endswith(".csv"):
137
+ df = pd.read_csv(file_obj)
138
+ elif file_name.endswith(".json"):
139
+ df = pd.read_json(file_obj)
140
  else:
141
+ return [], [], "Invalid file type. Only .csv and .json are supported."
142
+
143
  columns = df.columns.tolist()
144
  preview = df.head().to_markdown(index=False, numalign="left", stralign="left")
145
+ return columns, columns, preview # For two dropdowns + preview
146
+
147
  except Exception as e:
148
+ return [], [], f"Error reading file: {e}"
149
 
150
 
151
  def main_interface():
 
195
  file_input = gr.File(
196
  file_types=[".csv", ".json"], label="Upload a CSV or JSON file"
197
  )
198
+ gr.Markdown(
199
+ """
200
+ 📝 **Note:**
201
+ - **Model Output Column**: Select the column that contains generated responses, completions, or predictions from your model.
202
+ - **Training Data Column**: Select the column that may be used for future training or fine-tuning.
203
+ This helps MADGuard simulate feedback loops by comparing lexical and semantic overlap between current output and future inputs.
204
+ """
205
+ )
206
 
207
  with gr.Row():
208
  model_col_input = gr.Dropdown(
requirements.txt CHANGED
@@ -7,3 +7,4 @@ pandas
7
  scikit-learn
8
  sentence-transformers
9
  graphviz
 
 
7
  scikit-learn
8
  sentence-transformers
9
  graphviz
10
+ tabulate