egarciag commited on
Commit
a46511e
·
verified ·
1 Parent(s): 0b70c01

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -74
app.py CHANGED
@@ -178,80 +178,8 @@ custom_role_conversions=None,
178
  # Import tool from Hub
179
  search_tool = DuckDuckGoSearchTool()
180
 
181
- # with open("prompts.yaml", 'r') as stream:
182
- # prompt_templates = yaml.safe_load(stream)
183
-
184
- prompt_templates = """You are an expert assistant who can solve any task using code blobs. You will be given a task to solve as best you can.
185
- To do so, you have been given access to a list of tools: these tools are basically Python functions which you can call with code.
186
- To solve the task, you must plan forward to proceed in a series of steps, in a cycle of 'Thought:', 'Code:', and 'Observation:' sequences.
187
-
188
- At each step, in the 'Thought:' sequence, you should first explain your reasoning towards solving the task and the tools that you want to use.
189
- Then in the 'Code:' sequence, you should write the code in simple Python. The code sequence must end with '<end_code>' sequence.
190
- During each intermediate step, you can use 'print()' to save whatever important information you will then need.
191
- These print outputs will then appear in the 'Observation:' field, which will be available as input for the next step.
192
- In the end you have to return a final answer using the `final_answer` tool.
193
-
194
- On top of performing computations in the Python code snippets that you create, you only have access to these tools:
195
-
196
- def search_articles(search_term: str, start: int, end: int, output_md: str = "arxiv_articles.md") -> str:
197
- \"\"\"
198
- Searches for academic articles on arxiv.org using a given search term, retrieves
199
- results within a given range, and saves the output as a Markdown file.
200
-
201
- Args:
202
- search_term: The keyword or phrase to search for in ArXiv articles.
203
- start: The starting index of the search results (used for pagination).
204
- end: The number of articles to retrieve from the API.
205
- output_md: The name of the output Markdown file. Defaults to "arxiv_articles.md".
206
-
207
- Returns:
208
- str: The absolute path of the generated Markdown file, or an error message if the request fails.
209
-
210
- Example:
211
- >>> search_articles("deep learning", 0, 10)
212
- "Markdown file created: /absolute/path/to/arxiv_articles.md"
213
- \"\"\"
214
-
215
- def download_articles(article_links: list, save_folder: str = "downloads") -> str:
216
- \"\"\"
217
- A tool that downloads articles from arxiv.org given a list of links.
218
-
219
- Args:
220
- article_links: List of article links from ArXiv.
221
- save_folder: Folder to save downloaded articles. Default is 'downloads'.
222
-
223
- Returns:
224
- str: Success or error message.
225
- \"\"\"
226
-
227
- def create_zip_package(articles_folder: str, output_zip: str) -> str:
228
- \"\"\"
229
- A tool that packages all downloaded articles (PDFs) from a folder into a zip file.
230
-
231
- Args:
232
- articles_folder: Folder containing downloaded articles.
233
- output_zip: The name of the output zip file.
234
-
235
- Returns:
236
- str: Path to the created zip file.
237
- \"\"\"
238
-
239
- Here are the rules you should always follow to solve your task:
240
- 1. Always provide a 'Thought:' sequence, and a 'Code:\\n```py' sequence ending with '```<end_code>' sequence, else you will fail.
241
- 2. Use only variables that you have defined!
242
- 3. Always use the right arguments for the tools. DO NOT pass the arguments as a dict as in 'answer = wiki({'query': "What is the place where James Bond lives?"})',
243
- but use the arguments directly as in 'answer = wiki(query="What is the place where James Bond lives?")'.
244
- 4. Take care to not chain too many sequential tool calls in the same code block, especially when the output format is unpredictable.
245
- For instance, a call to search has an unpredictable return format, so do not have another tool call that depends on its output in the
246
- same block: rather output results with print() to use them in the next block.
247
- 5. Call a tool only when needed, and never re-do a tool call that you previously did with the exact same parameters.
248
- 6. Don't name any new variable with the same name as a tool: for instance don't name a variable 'final_answer'.
249
- 7. Never create any notional variables in our code, as having these in your logs might derail you from the true variables.
250
- 8. You can use imports in your code, but only from the following list of modules: {{authorized_imports}}
251
- 9. The state persists between code executions: so if in one step you've created variables or imported modules, these will all persist.
252
- 10. Don't give up! You're in charge of solving the task, not providing directions to solve it.
253
-
254
- Now Begin! If you solve the task correctly, you will receive a reward of $1,000,000."""
255
 
256
  agent = CodeAgent(
257
  model=model,
 
178
  # Import tool from Hub
179
  search_tool = DuckDuckGoSearchTool()
180
 
181
+ with open("prompts.yaml", 'r') as stream:
182
+ prompt_templates = yaml.safe_load(stream)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
  agent = CodeAgent(
185
  model=model,