cowrycode commited on
Commit
568dfc0
·
verified ·
1 Parent(s): 98a3f5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -42
app.py CHANGED
@@ -46,32 +46,6 @@ class BasicAgent:
46
  return self.run(question)
47
  #return self.agent.run(question)
48
 
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
- # START MY CODE
57
-
58
- # print("BasicAgent initialized.")
59
- # api_key = os.getenv("HF_TOKEN")
60
- # llm = HuggingFaceInferenceAPI(
61
- # model_name="deepseek-ai/DeepSeek-R1-0528",
62
- # token=api_key,
63
- # provider="auto",
64
- # max_iterations=10,
65
- # max_execution_time=60
66
- # )
67
- # agent = AgentWorkflow.from_tools_or_functions(
68
- # [wikipedia_search_tool, youtube_transcript_tool, youtube_transcript_snippet_tool,
69
- # round_to_two_decimals_tool, text_inverter_tool, google_web_search_tool],
70
- # llm=llm
71
- # )
72
-
73
- # END MY CODE
74
-
75
  def run_and_submit_all( profile: gr.OAuthProfile | None):
76
  """
77
  Fetches all questions, runs the BasicAgent on them, submits all answers,
@@ -145,22 +119,29 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
145
  # return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
146
 
147
  #3A
148
- async def run_all_questions(questions_data):
149
- answers_payload = []
150
- for item in questions_data:
151
- task_id = item.get("task_id")
152
- question_text = item.get("question")
153
- if not task_id or question_text is None:
154
- print(f"Skipping item with missing task_id or question: {item}")
155
- continue
156
- try:
157
- answer = await agent.run(question_text) # await coroutine
158
- answers_payload.append({"task_id": task_id, "submitted_answer": answer})
159
- print(f"Answered Task {task_id}: {answer[:50]}...")
160
- except Exception as e:
161
- answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
162
- print(f"Error on Task {task_id}: {e}")
163
- return answers_payload
 
 
 
 
 
 
 
164
 
165
  answers_payload = asyncio.run(run_all_questions(questions_data))
166
 
 
46
  return self.run(question)
47
  #return self.agent.run(question)
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  def run_and_submit_all( profile: gr.OAuthProfile | None):
50
  """
51
  Fetches all questions, runs the BasicAgent on them, submits all answers,
 
119
  # return "Agent did not produce any answers to submit.", pd.DataFrame(results_log)
120
 
121
  #3A
122
+ question_text = questions_data[0].get("question")
123
+ task_id = questions_data[0].get("task_id")
124
+ print(f"Processing my question 0 : : : : : : :")
125
+ agent.run(question_text)
126
+ print(f"Answered Task {task_id}: {answer[:50]}...")
127
+ answers_payload = []
128
+ answers_payload.append({"task_id": task_id, "submitted_answer": answer})
129
+ # async def run_all_questions(questions_data):
130
+ # answers_payload = []
131
+ # for item in questions_data:
132
+ # task_id = item.get("task_id")
133
+ # question_text = item.get("question")
134
+ # if not task_id or question_text is None:
135
+ # print(f"Skipping item with missing task_id or question: {item}")
136
+ # continue
137
+ # try:
138
+ # answer = await agent.run(question_text) # await coroutine
139
+ # answers_payload.append({"task_id": task_id, "submitted_answer": answer})
140
+ # print(f"Answered Task {task_id}: {answer[:50]}...")
141
+ # except Exception as e:
142
+ # answers_payload.append({"task_id": task_id, "submitted_answer": f"AGENT ERROR: {e}"})
143
+ # print(f"Error on Task {task_id}: {e}")
144
+ # return answers_payload
145
 
146
  answers_payload = asyncio.run(run_all_questions(questions_data))
147