Gonzalo Lope commited on
Commit
a186feb
·
1 Parent(s): 81917a3

added logger of questions

Browse files
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .env
__pycache__/smolagents.cpython-311.pyc ADDED
Binary file (721 Bytes). View file
 
__pycache__/smolagents_test.cpython-311.pyc ADDED
Binary file (856 Bytes). View file
 
app.py CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
 
 
6
 
7
  # (Keep Constants as is)
8
  # --- Constants ---
@@ -13,11 +15,16 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
  class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
 
16
  def __call__(self, question: str) -> str:
17
- print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
 
 
 
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
@@ -74,6 +81,10 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
74
  answers_payload = []
75
  print(f"Running agent on {len(questions_data)} questions...")
76
  for item in questions_data:
 
 
 
 
77
  task_id = item.get("task_id")
78
  question_text = item.get("question")
79
  if not task_id or question_text is None:
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents_test import agent
7
+ import json
8
 
9
  # (Keep Constants as is)
10
  # --- Constants ---
 
15
  class BasicAgent:
16
  def __init__(self):
17
  print("BasicAgent initialized.")
18
+ self.agent = agent # Use the imported agent from smolagents_test.py
19
  def __call__(self, question: str) -> str:
20
+ # Add question to a file
21
+ with open("questions.txt", "a") as f:
22
+ f.write(f"{question}\n{'-'*50}\n")
23
+
24
+ print(f"Agent received question (first 50 chars): {question}...")
25
+ answer = self.agent.run(question)
26
+ print(f"Agent returning fixed answer: {answer}")
27
+ return answer
28
 
29
  def run_and_submit_all( profile: gr.OAuthProfile | None):
30
  """
 
81
  answers_payload = []
82
  print(f"Running agent on {len(questions_data)} questions...")
83
  for item in questions_data:
84
+ # Add question data to a json file
85
+ with open("questions.json", "a") as f:
86
+ json.dump(item, f)
87
+ f.write("\n")
88
  task_id = item.get("task_id")
89
  question_text = item.get("question")
90
  if not task_id or question_text is None:
questions.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "questions": [
3
+ "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.",
4
+ "In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?",
5
+ ".rewsna eht sa 'tfel' drow eht fo etisoppo eht etirw ,ecnetnes siht dnatsrednu uoy fI",
6
+ "Review the chess position provided in the image. It is black's turn. Provide the correct next move for black which guarantees a win. Please provide your response in algebraic notation.",
7
+ "Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?",
8
+
9
+ "Given this table defining * on the set S = {a, b, c, d, e}\n\n|*|a|b|c|d|e|\n|---|---|---|---|---|---|\n|a|a|b|c|b|d|\n|b|b|c|a|e|c|\n|c|c|a|b|b|a|\n|d|b|e|b|e|d|\n|e|d|b|a|d|c|\n\nprovide the subset of S involved in any possible counter-examples that prove * is not commutative. Provide your answer as a comma separated list of the elements in the set in alphabetical order.",
10
+ "Examine the video at https://www.youtube.com/watch?v=1htKBjuUWec.\n\nWhat does Teal'c say in response to the question 'Isn't that hot?'",
11
+ "What is the surname of the equine veterinarian mentioned in 1.E Exercises from the chemistry materials licensed by Marisa Alviar-Agnew & Henry Agnew under the CK-12 license in LibreText's Introductory Chemistry materials as compiled 08/21/2023?",
12
+ "I'm making a grocery list for my mom, but she's a professor of botany and she's a real stickler when it comes to categorizing things. I need to add different foods to different categories on the grocery list, but if I make a mistake, she won't buy anything inserted in the wrong category. Here's the list I have so far:\n\nmilk, eggs, flour, whole bean coffee, Oreos, sweet potatoes, fresh basil, plums, green beans, rice, corn, bell pepper, whole allspice, acorns, broccoli, celery, zucchini, lettuce, peanuts\n\nI need to make headings for the fruits and vegetables. Could you please create a list of just the vegetables from my list? If you could do that, then I can figure out how to categorize the rest of the list into the appropriate categories. But remember that my mom is a real stickler, so make sure that no botanical fruits end up on the vegetable list, or she won't get them when she's at the store. Please alphabetize the list of vegetables, and place each item in a comma separated list.",
13
+ "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations.","What country had the least number of athletes at the 1928 Summer Olympics? If there's a tie for a number of athletes, return the first in alphabetical order. Give the IOC country code as your answer.",
14
+ "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.",
15
+ "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.",
16
+ "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?",
17
+ ]
18
+ }
smolagents_test.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import login
2
+ from smolagents import CodeAgent, DuckDuckGoSearchTool, OpenAIServerModel
3
+
4
+
5
+ model_ctc = OpenAIServerModel(
6
+ model_id="google/gemma-3-27b-it",
7
+ api_key="EMPTY",
8
+ api_base="http://10.10.48.10:8088/v1"
9
+ )
10
+
11
+
12
+
13
+ agent = CodeAgent(tools=[], model=model_ctc)
14
+
15
+
16
+ if __name__ == "__main__":
17
+ agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")