Spaces:
Sleeping
Sleeping
| import requests | |
| from agent import agent # Imports the agent function from agent.py | |
| HF_USERNAME = "wowpixels" # Replace with your actual HF username | |
| CODE_LINK = "https://huggingface.co/spaces/wowpixels/Perfume-recommender-agent/tree/main" | |
| BASE_URL = "https://gaia.evaluation.huggingface.co" | |
| GET_RANDOM_QUESTION = f"{BASE_URL}/random-question" | |
| SUBMIT_ANSWER = f"{BASE_URL}/submit" | |
| def main(): | |
| print("π Fetching a random GAIA evaluation question...") | |
| try: | |
| res = requests.get(GET_RANDOM_QUESTION) | |
| res.raise_for_status() | |
| except Exception as e: | |
| print("β Failed to fetch GAIA question:", e) | |
| return | |
| question_obj = res.json() | |
| task_id = question_obj["task_id"] | |
| question = question_obj["question"] | |
| print(f"π Task ID: {task_id}") | |
| print(f"π¬ Question: {question}") | |
| try: | |
| answer = agent(question) | |
| except Exception as e: | |
| print("β Agent failed to produce answer:", e) | |
| return | |
| print(f"β Answer: {answer}") | |
| payload = { | |
| "username": HF_USERNAME, | |
| "agent_code": CODE_LINK, | |
| "answers": [ | |
| { | |
| "task_id": task_id, | |
| "submitted_answer": answer | |
| } | |
| ] | |
| } | |
| print("π€ Submitting answer...") | |
| try: | |
| submit_res = requests.post(SUBMIT_ANSWER, json=payload) | |
| submit_res.raise_for_status() | |
| print("π Submitted successfully!") | |
| print("π― Response:", submit_res.json()) | |
| except Exception as e: | |
| print("β Submission failed:", e) | |
| if __name__ == "__main__": | |
| main() | |