Facelook commited on
Commit
0aa6fa5
·
1 Parent(s): 607fb80

Modified system instruction to generate search questions.

Browse files
Files changed (1) hide show
  1. app.py +28 -25
app.py CHANGED
@@ -13,8 +13,6 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
 
14
  # --- Basic Agent Definition ---
15
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
16
-
17
-
18
  class BasicAgent:
19
  def __init__(self):
20
  print("BasicAgent initialized.")
@@ -77,7 +75,7 @@ class BasicAgent:
77
  return []
78
 
79
  def __call__(self, question: str) -> str:
80
- print(f"Agent received question: {question}...")
81
 
82
  try:
83
  tools = [
@@ -112,7 +110,8 @@ class BasicAgent:
112
  messages = [
113
  {
114
  "role": "system",
115
- "content": "You are a general AI assistant. I will ask you a question. Read the question carefully. Break down the question into multiple questions and use the tools available to you to answer the question. Do not report your thoughts, only give YOUR FINAL ANSWER. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.",
 
116
  },
117
  {
118
  "role": "user",
@@ -142,11 +141,14 @@ class BasicAgent:
142
  },
143
  extra_body={},
144
  # model="meta-llama/llama-4-scout:free",
145
- model="meta-llama/llama-4-maverick:free",
146
  # model="google/gemini-2.0-flash-exp:free",
147
  # model="mistralai/mistral-small-3.1-24b-instruct:free",
148
- #tools=tools,
149
- messages=messages
 
 
 
150
  )
151
 
152
  messages.append(completion.choices[0].message)
@@ -304,12 +306,12 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
304
  # 'Level': '1',
305
  # 'file_name': 'f918266a-b3e0-4914-865d-4faa564f1aef.py'
306
  # },
307
- # {
308
- # 'task_id': '3f57289b-8c60-48be-bd80-01f8099ca449',
309
- # 'question': 'How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?',
310
- # 'Level': '1',
311
- # 'file_name': ''
312
- # },
313
  # {
314
  # 'task_id': '1f975693-876d-457b-a649-393859e79bf3',
315
  # 'question': "Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.",
@@ -335,28 +337,29 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
335
  # 'file_name': ''
336
  # },
337
  # {
338
- # 'task_id': 'a0c07678-e491-4bbc-8f0b-07405144218f',
339
- # 'question': "Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.",
340
- # 'Level': '1',
341
- # 'file_name': ''},
 
342
  # {
343
  # 'task_id': '7bd855d8-463d-4ed5-93ca-5fe35145f733',
344
  # 'question': 'The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.',
345
  # 'Level': '1',
346
  # 'file_name': '7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx'
347
  # },
348
- {
349
- 'task_id': '5a0c1adf-205e-4841-a666-7c3ef95def9d',
350
- 'question': 'What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?',
351
- 'Level': '1',
352
- 'file_name': ''
353
- },
354
  ]
355
 
356
  # 3. Run your Agent
357
  results_log = []
358
  answers_payload = []
359
- print(f"Running agent on {len(questions_data)} questions...")
360
  for item in questions_data:
361
  task_id = item.get("task_id")
362
  question_text = item.get("question")
@@ -377,7 +380,7 @@ def run_and_submit_all(profile: gr.OAuthProfile | None):
377
 
378
  # 4. Prepare Submission
379
  submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
380
- status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'..."
381
  print(status_update)
382
 
383
  # 5. Submit
 
13
 
14
  # --- Basic Agent Definition ---
15
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
 
16
  class BasicAgent:
17
  def __init__(self):
18
  print("BasicAgent initialized.")
 
75
  return []
76
 
77
  def __call__(self, question: str) -> str:
78
+ print(f"Agent received question: {question}")
79
 
80
  try:
81
  tools = [
 
110
  messages = [
111
  {
112
  "role": "system",
113
+ # "content": "You are a general AI assistant. I will ask you a question. Read the question carefully. Break down the question into multiple questions and use the tools available to you to answer the question. Do not report your thoughts, explanations, reasoning, or conclusion. Give only YOUR FINAL ANSWER. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.",
114
+ "content": "Read the question carefully. Do not report your thoughts, explanations, reasoning, or conclusion. If you know the answer, give only YOUR FINAL ANSWER. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string. On the other hand, if you don't know the answer, break down the question and list all questions that you want to search in a string array.",
115
  },
116
  {
117
  "role": "user",
 
141
  },
142
  extra_body={},
143
  # model="meta-llama/llama-4-scout:free",
144
+ # model="meta-llama/llama-4-maverick:free",
145
  # model="google/gemini-2.0-flash-exp:free",
146
  # model="mistralai/mistral-small-3.1-24b-instruct:free",
147
+ model="deepseek/deepseek-chat-v3-0324:free",
148
+ # tools=tools,
149
+ messages=messages,
150
+ temperature=0.0,
151
+ max_tokens=1024,
152
  )
153
 
154
  messages.append(completion.choices[0].message)
 
306
  # 'Level': '1',
307
  # 'file_name': 'f918266a-b3e0-4914-865d-4faa564f1aef.py'
308
  # },
309
+ {
310
+ 'task_id': '3f57289b-8c60-48be-bd80-01f8099ca449',
311
+ 'question': 'How many at bats did the Yankee with the most walks in the 1977 regular season have that same season?',
312
+ 'Level': '1',
313
+ 'file_name': ''
314
+ },
315
  # {
316
  # 'task_id': '1f975693-876d-457b-a649-393859e79bf3',
317
  # 'question': "Hi, I was out sick from my classes on Friday, so I'm trying to figure out what I need to study for my Calculus mid-term next week. My friend from class sent me an audio recording of Professor Willowbrook giving out the recommended reading for the test, but my headphones are broken :(\n\nCould you please listen to the recording for me and tell me the page numbers I'm supposed to go over? I've attached a file called Homework.mp3 that has the recording. Please provide just the page numbers as a comma-delimited list. And please provide the list in ascending order.",
 
337
  # 'file_name': ''
338
  # },
339
  # {
340
+ # 'task_id': 'a0c07678-e491-4bbc-8f0b-07405144218f',
341
+ # 'question': "Who are the pitchers with the number before and after Taishō Tamai's number as of July 2023? Give them to me in the form Pitcher Before, Pitcher After, use their last names only, in Roman characters.",
342
+ # 'Level': '1',
343
+ # 'file_name': ''
344
+ # },
345
  # {
346
  # 'task_id': '7bd855d8-463d-4ed5-93ca-5fe35145f733',
347
  # 'question': 'The attached Excel file contains the sales of menu items for a local fast-food chain. What were the total sales that the chain made from food (not including drinks)? Express your answer in USD with two decimal places.',
348
  # 'Level': '1',
349
  # 'file_name': '7bd855d8-463d-4ed5-93ca-5fe35145f733.xlsx'
350
  # },
351
+ # {
352
+ # 'task_id': '5a0c1adf-205e-4841-a666-7c3ef95def9d',
353
+ # 'question': 'What is the first name of the only Malko Competition recipient from the 20th Century (after 1977) whose nationality on record is a country that no longer exists?',
354
+ # 'Level': '1',
355
+ # 'file_name': ''
356
+ # },
357
  ]
358
 
359
  # 3. Run your Agent
360
  results_log = []
361
  answers_payload = []
362
+ print(f"Running agent on {len(questions_data)} questions")
363
  for item in questions_data:
364
  task_id = item.get("task_id")
365
  question_text = item.get("question")
 
380
 
381
  # 4. Prepare Submission
382
  submission_data = {"username": username.strip(), "agent_code": agent_code, "answers": answers_payload}
383
+ status_update = f"Agent finished. Submitting {len(answers_payload)} answers for user '{username}'"
384
  print(status_update)
385
 
386
  # 5. Submit