Spaces:
Sleeping
Sleeping
Improve step data saving
Browse files
app.py
CHANGED
@@ -39,13 +39,12 @@ columns = [
|
|
39 |
# FinalAnswerStep attributes
|
40 |
'final_answer'
|
41 |
]
|
42 |
-
df_agent_steps = pd.DataFrame(columns=columns)
|
43 |
|
44 |
class BasicAgent:
|
45 |
def __init__(self):
|
46 |
self.agent = master_agent
|
47 |
print("Master Agent initialized.")
|
48 |
-
def __call__(self, question: str, task_id: str) -> str:
|
49 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
50 |
fixed_answer = self.agent.run(question)
|
51 |
all_steps = self.agent.memory.get_full_steps()
|
@@ -71,7 +70,7 @@ class BasicAgent:
|
|
71 |
df_agent_steps.at[len(df_agent_steps), key] = value
|
72 |
|
73 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
74 |
-
return fixed_answer
|
75 |
|
76 |
def run_and_submit_all( profile: gr.OAuthProfile | None, mock_submission: bool = False):
|
77 |
"""
|
@@ -126,6 +125,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None, mock_submission: bool =
|
|
126 |
# 3. Run your Agent
|
127 |
results_log = []
|
128 |
answers_payload = []
|
|
|
129 |
print(f"Running agent on {len(questions_data)} questions...")
|
130 |
for item in questions_data:
|
131 |
task_id = item.get("task_id")
|
@@ -139,7 +139,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None, mock_submission: bool =
|
|
139 |
try:
|
140 |
if file_path:
|
141 |
question_text = question_text + f"\n\nHere is also the path to the file for the task (file name matches with task ID and is not in plain English): {file_path}"
|
142 |
-
submitted_answer = agent(question_text, task_id)
|
143 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
144 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
145 |
except Exception as e:
|
|
|
39 |
# FinalAnswerStep attributes
|
40 |
'final_answer'
|
41 |
]
|
|
|
42 |
|
43 |
class BasicAgent:
|
44 |
def __init__(self):
|
45 |
self.agent = master_agent
|
46 |
print("Master Agent initialized.")
|
47 |
+
def __call__(self, question: str, task_id: str, df_agent_steps: pd.DataFrame) -> str:
|
48 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
49 |
fixed_answer = self.agent.run(question)
|
50 |
all_steps = self.agent.memory.get_full_steps()
|
|
|
70 |
df_agent_steps.at[len(df_agent_steps), key] = value
|
71 |
|
72 |
print(f"Agent returning fixed answer: {fixed_answer}")
|
73 |
+
return fixed_answer, df_agent_steps
|
74 |
|
75 |
def run_and_submit_all( profile: gr.OAuthProfile | None, mock_submission: bool = False):
|
76 |
"""
|
|
|
125 |
# 3. Run your Agent
|
126 |
results_log = []
|
127 |
answers_payload = []
|
128 |
+
df_agent_steps = pd.DataFrame(columns=columns)
|
129 |
print(f"Running agent on {len(questions_data)} questions...")
|
130 |
for item in questions_data:
|
131 |
task_id = item.get("task_id")
|
|
|
139 |
try:
|
140 |
if file_path:
|
141 |
question_text = question_text + f"\n\nHere is also the path to the file for the task (file name matches with task ID and is not in plain English): {file_path}"
|
142 |
+
submitted_answer, df_agent_steps = agent(question_text, task_id, df_agent_steps)
|
143 |
answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
|
144 |
results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
|
145 |
except Exception as e:
|