Spaces:
Build error
Build error
Commit ·
ab7953b
1
Parent(s): 96acbd9
better agent submition
Browse files84 unmodified lines858687888889909192939430 unmodified lines12512612712812913013113213313413513613713813914014114214314414513014614714814915015115284 unmodified lines return {"Task ID": task_id, "Question": question_text, "Submitted Answer": "SKIPPED"}, None try: submitted_answer = await agent.aquery(question_text) return {"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer}, {"task_id": task_id, "submitted_answer": submitted_answer} # Ensure consistent data types for payload safe_task_id = str(task_id) safe_answer = str(submitted_answer) return {"Task ID": safe_task_id, "Question": question_text, "Submitted Answer": safe_answer}, {"task_id": safe_task_id, "submitted_answer": safe_answer} except Exception as e: print(f"Error running agent on task {task_id}: {e}") return {"Task ID": task_id, "Question": question_text, "Submitted Answer": f"AGENT ERROR: {e}"}, None30 unmodified lines api_url = DEFAULT_API_URL submit_url = f"{api_url}/submit" agent_code = f"https://huggingface.co/spaces/{space_id}/tree/main" # Detailed logging for the submission payload (only first 3 answers to avoid clutter) preview_answers = cached_answers[:3] if cached_answers else [] print("\n--- Submission Payload Preview ---") print(f"Username: {username.strip()}") print(f"Agent Code: {agent_code}") print(f"Total Answers: {len(cached_answers)}") print(f"First Answers Sample: {preview_answers}") print("----------------------------------\n")
submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": cached_answers} print(f"Submitting {len(cached_answers)} answers to: {submit_url}") try: response = requests.post(submit_url, json=submission_data, timeout=60) response.raise_for_status() print(f"Submit endpoint status code: {response.status_code}") print(f"Raw response text: {response.text[:500]}") # Attempt to parse JSON regardless of status for troubleshooting try: result_data = response.json() result_data = response.json() except Exception as json_err: print(f"Error parsing JSON response: {json_err}") raise final_status = ( f"Submission Successful!\n" f"User: {result_data.get('username')}\n"app.py+21-2