huytofu92 commited on
Commit
32b7d7a
·
1 Parent(s): 8ed7d27

Last fix to agent

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -143,7 +143,14 @@ def save_dataset_to_hub(df: pd.DataFrame, dataset_name: str) -> tuple[bool, str]
143
  # Convert complex types to strings before creating dataset
144
  for col in df.columns:
145
  if df[col].dtype == 'object':
146
- df[col] = df[col].apply(lambda x: str(x) if pd.notnull(x) else None)
 
 
 
 
 
 
 
147
 
148
  # Convert to dataset
149
  dataset = datasets.Dataset.from_pandas(df)
@@ -241,7 +248,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None, mock_submission: bool =
241
  answers_payload = []
242
  df_agent_steps = pd.DataFrame(columns=columns)
243
  print(f"Running agent on {len(questions_data)} questions...")
244
- for item in questions_data[:1]:
245
  task_id = item.get("task_id")
246
  question_text = item.get("question")
247
  file_path = get_full_file_path(task_id)
 
143
  # Convert complex types to strings before creating dataset
144
  for col in df.columns:
145
  if df[col].dtype == 'object':
146
+ def safe_convert(x):
147
+ if x is None or x == "None":
148
+ return None
149
+ if isinstance(x, (list, tuple, dict)):
150
+ return str(x)
151
+ return str(x) if pd.notna(x) else None
152
+
153
+ df[col] = df[col].apply(safe_convert)
154
 
155
  # Convert to dataset
156
  dataset = datasets.Dataset.from_pandas(df)
 
248
  answers_payload = []
249
  df_agent_steps = pd.DataFrame(columns=columns)
250
  print(f"Running agent on {len(questions_data)} questions...")
251
+ for item in questions_data[1:2]:
252
  task_id = item.get("task_id")
253
  question_text = item.get("question")
254
  file_path = get_full_file_path(task_id)