razvan-horobeanu commited on
Commit
008c3ab
·
verified ·
1 Parent(s): cf3595d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -27,7 +27,7 @@ visit_webpage = VisitWebpage()
27
  with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
28
  prompt_templates = yaml.safe_load(stream)
29
 
30
- agent = CodeAgent(
31
  model=model,
32
  tools=[web_search, visit_webpage],
33
  max_steps=10,
@@ -38,14 +38,14 @@ agent = CodeAgent(
38
  )
39
 
40
  # --- from template
41
- class BasicAgent():
42
- def __init__(self):
43
- print("BasicAgent initialized.")
44
- def __call__(self, question: str) -> str:
45
- print(f"Agent received question (first 50 chars): {question[:50]}...")
46
- fixed_answer = agent(question)
47
- print(f"Agent returning fixed answer: {fixed_answer}")
48
- return fixed_answer
49
 
50
  def run_and_submit_all( profile: gr.OAuthProfile | None):
51
  """
@@ -68,7 +68,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
68
 
69
  # 1. Instantiate Agent ( modify this part to create your agent)
70
  try:
71
- agent = BasicAgent()
 
72
  except Exception as e:
73
  print(f"Error instantiating agent: {e}")
74
  return f"Error initializing agent: {e}", None
@@ -108,7 +109,7 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
108
  print(f"Skipping item with missing task_id or question: {item}")
109
  continue
110
  try:
111
- submitted_answer = agent(question_text)
112
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
113
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
114
  except Exception as e:
 
27
  with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
28
  prompt_templates = yaml.safe_load(stream)
29
 
30
+ agent2 = CodeAgent(
31
  model=model,
32
  tools=[web_search, visit_webpage],
33
  max_steps=10,
 
38
  )
39
 
40
  # --- from template
41
+ #class BasicAgent():
42
+ # def __init__(self):
43
+ # print("BasicAgent initialized.")
44
+ # def __call__(self, question: str) -> str:
45
+ # print(f"Agent received question (first 50 chars): {question[:50]}...")
46
+ # fixed_answer = agent(question)
47
+ # print(f"Agent returning fixed answer: {fixed_answer}")
48
+ # return fixed_answer
49
 
50
  def run_and_submit_all( profile: gr.OAuthProfile | None):
51
  """
 
68
 
69
  # 1. Instantiate Agent ( modify this part to create your agent)
70
  try:
71
+ #agent = BasicAgent()
72
+ agent = CodeAgent()
73
  except Exception as e:
74
  print(f"Error instantiating agent: {e}")
75
  return f"Error initializing agent: {e}", None
 
109
  print(f"Skipping item with missing task_id or question: {item}")
110
  continue
111
  try:
112
+ submitted_answer = agent2(question_text) # modified
113
  answers_payload.append({"task_id": task_id, "submitted_answer": submitted_answer})
114
  results_log.append({"Task ID": task_id, "Question": question_text, "Submitted Answer": submitted_answer})
115
  except Exception as e: