Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456781 unmodified line1011121314151617181920212223122 unmodified lines146147148149150151152153154155156import osimport gradio as grimport requestsimport inspectimport pandas as pd# (Keep Constants as is)# --- Constants ---1 unmodified line# --- Basic Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:def __init__(self):print("BasicAgent initialized.")def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")fixed_answer = "This is a default answer."print(f"Agent returning fixed answer: {fixed_answer}")return fixed_answerdef run_and_submit_all( profile: gr.OAuthProfile | None):"""122 unmodified linesgr.Markdown("""**Instructions:**1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.---**Disclaimers:**Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).1234567891011121 unmodified line14151617181920212223242526272829303132333435122 unmodified lines158159160161162163164165166import osimport inspectimport gradio as grimport requestsimport pandas as pdfrom langchain_core.messages import HumanMessagefrom agent import build_graph# (Keep Constants as is)# --- Constants ---1 unmodified line# --- Basic Agent Definition ---# ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------class BasicAgent:"""A langgraph agent."""def __init__(self):print("BasicAgent initialized.")self.graph = build_graph()def __call__(self, question: str) -> str:print(f"Agent received question (first 50 chars): {question[:50]}...")# Wrap the question in a HumanMessage from langchain_coremessages = [HumanMessage(content=question)]messages = self.graph.invoke({"messages": messages})answer = messages['messages'][-1].contentreturn answer[14:]def run_and_submit_all( profile: gr.OAuthProfile | None):"""122 unmodified linesgr.Markdown("""**Instructions:**1. Please clone this space, then modify the code to define your agent's logic, the tools, the necessary packages, etc ...2. Log in to your Hugging Face account using the button below. This uses your HF username for submission.3. Click 'Run Evaluation & Submit All Answers' to fetch questions, run your agent, submit answers, and see the score.---**Disclaimers:**Once clicking on the "submit button, it can take quite some time ( this is the time for the agent to go through all the questions).
app.py+16-6