Andrei Nazarov commited on
Commit
192860a
·
1 Parent(s): eace4bc

updated 13

Browse files
Files changed (1) hide show
  1. app.py +26 -39
app.py CHANGED
@@ -55,66 +55,53 @@ class GeminiModel(Model):
55
  self.rate_limiter = RateLimiter(requests_per_minute=25) # Setting to 25 to be safe
56
 
57
  # System prompt for smolagents format
58
- self.system_prompt = """You are a highly capable agent. Your goal is to answer the user's question accurately.
 
 
59
 
60
- **INSTRUCTIONS:**
61
- 1. **Think:** First, in a `Thought:` block, break down the question and create a clear plan to find the answer.
62
- 2. **Code:** Then, in a `Code:` block, write a Python script to execute your plan.
63
- - Use the available tools: `wikipedia_search(query)` and `web_search(query)`.
64
- - You can process the results of your searches within the script.
65
- - Your script **MUST** end with a call to `final_answer(your_final_answer)`.
66
-
67
- **TOOLS:**
68
- - `wikipedia_search(query: str)`: Best for specific, factual, encyclopedic questions.
69
- - `web_search(query: str)`: Good for general questions, current events, or when Wikipedia doesn't have an answer.
70
- - `final_answer(answer: str)`: The last call you make. It submits the final answer.
71
 
72
  ---
 
 
 
73
 
74
- **EXAMPLE 1: Factual Wikipedia Question**
75
- *Question:* How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)?
76
 
77
- *Your Response:*
78
- Thought: The user is asking for a specific number of albums from a specific artist in a specific timeframe. `wikipedia_search` is the best tool for this. I will find the discography and count the studio albums within the specified years.
79
  Code:
80
  ```py
81
- # I will search Wikipedia for the discography and then process the results.
82
- # Based on the discography, the studio albums in the period are:
83
- # Acústico (2002), Corazón libre (2005), Cantora 1 (2009), and Cantora 2 (2009).
84
- # That makes a total of 4 albums.
85
- final_answer("4")
86
  ```<end_code>
87
 
88
  ---
 
 
89
 
90
- **EXAMPLE 2: Video Content Question**
91
- *Question:* In the video https://www.youtube.com/watch?v=L1vXCYZAYYM, what is the highest number of bird species to be on camera simultaneously?
92
 
93
- *Your Response:*
94
- Thought: I cannot watch videos, so I must search for articles or descriptions of the video content. I will use `web_search` with the video ID to find this information.
95
  Code:
96
  ```py
97
- # I will search for descriptions of the YouTube video.
98
- # A search for "YouTube L1vXCYZAYYM bird species" should provide info.
99
- # The search results indicate the video shows Emperor penguin chicks, an Adelie penguin, and a giant petrel.
100
- # That is a total of 3 species.
101
- final_answer("3")
102
  ```<end_code>
103
 
104
  ---
 
 
105
 
106
- **EXAMPLE 3: Specific Factual Lookup**
107
- *Question:* Who nominated the only Featured Article on English Wikipedia about a dinosaur that was promoted in November 2016?
108
 
109
- *Your Response:*
110
- Thought: This is a very specific question about Wikipedia's history. I need to find the list of Featured Articles promoted in November 2016, find the dinosaur article, and then find who nominated it.
111
  Code:
112
  ```py
113
- # I will search for "Wikipedia Featured articles promoted November 2016".
114
- # The results show the article for "Psittacosaurus" was promoted.
115
- # Now I will search for "Wikipedia Psittacosaurus featured article nomination".
116
- # The nomination page shows it was nominated by user "Ucucha".
117
- final_answer("Ucucha")
118
  ```<end_code>
119
  """
120
 
 
55
  self.rate_limiter = RateLimiter(requests_per_minute=25) # Setting to 25 to be safe
56
 
57
  # System prompt for smolagents format
58
+ self.system_prompt = """You are a reasoning agent that solves problems by breaking them down into steps. You are in a loop. In each turn, you will take one of two actions:
59
+ 1. **Think and Search:** Use a `Thought:` block to analyze the problem and decide what information you need next. Then use a `Code:` block to call ONE search tool (`web_search` or `wikipedia_search`) to get that information.
60
+ 2. **Think and Answer:** If you have all the information you need, use a `Thought:` block to explain how you will construct the final answer. Then use a `Code:` block to call `final_answer()` with the result.
61
 
62
+ **CRITICAL RULES:**
63
+ - **One step at a time.** Your `Code:` block should only contain a SINGLE action (one search, or the final answer).
64
+ - Use the `Observation:` from the previous step to inform your next `Thought:`.
65
+ - You MUST call `final_answer()` to finish the task. Do not just state the answer in your thoughts.
 
 
 
 
 
 
 
66
 
67
  ---
68
+ **EXAMPLE: Solving a multi-step problem**
69
+
70
+ *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.
71
 
72
+ ---
73
+ **Your Turn 1**
74
 
75
+ Thought: I need to find out Taishō Tamai's jersey number and his team as of July 2023. I'll use a web search for this.
 
76
  Code:
77
  ```py
78
+ web_search(query="Taisho Tamai jersey number and team July 2023")
 
 
 
 
79
  ```<end_code>
80
 
81
  ---
82
+ *(You will receive an Observation with the search results)*
83
+ **Observation:** Taishō Tamai is a pitcher for the Orix Buffaloes, jersey number 61.
84
 
85
+ ---
86
+ **Your Turn 2**
87
 
88
+ Thought: Great, his number is 61 and he plays for the Orix Buffaloes. Now I need to find the 2023 pitcher roster for that team to see who has numbers 60 and 62.
 
89
  Code:
90
  ```py
91
+ web_search(query="Orix Buffaloes 2023 pitcher roster with jersey numbers")
 
 
 
 
92
  ```<end_code>
93
 
94
  ---
95
+ *(You will receive another Observation with the new search results)*
96
+ **Observation:** The Orix Buffaloes 2023 roster includes... Pitcher: K. Mizuno, #60... Pitcher: T. Onaga, #62...
97
 
98
+ ---
99
+ **Your Turn 3**
100
 
101
+ Thought: I have all the information. The pitcher before is Mizuno and the one after is Onaga. The required format is "LastNameBefore, LastNameAfter".
 
102
  Code:
103
  ```py
104
+ final_answer("Mizuno, Onaga")
 
 
 
 
105
  ```<end_code>
106
  """
107